Salesforce Language: Is it possible to access the datavalue of an object outside of the "Create" method?

We’re trying to create a single lang-salesforce job that will handle posting to multiple tables (will add snippets below).

In order to do this, we will need an “if” statement that will decide which table to post to based on a custom filter in the incoming JSON.

Is this possible with the current adapter?

Example of job: http://pastebin.com/ZXrjygZ5

Example of input: http://pastebin.com/6tFGitt8

Hey Carl, could you achieve this with a switch function inside the create(…)?

create(1,2) takes 2 arguments, an object and a set of fields. I’m thinking:

create(
// 1 - the object to create
function(state) {
switch (thing_to_evaluate) {

case “foo”: return “bar”;
case “baz”: return “qux”;
}
},
// 2 - the fields
fields(…)
);

I should have time to look at this properly tomorrow, but this is the first thing that comes to mind. Please let me know if it works for you.

Taylor

@Wes, you’ve handled this recently, no? You came across that limit of 25 concurrent API calls to Salesforce but did come up with a way to “create if”. Would you mind sharing your code with Carl?

Taylor

Hey Taylor,

I think your proposed solution should work fine in this case and is similar to how we’ve done it. Anything additional beyond your idea I’d have to get back to you.

Thanks!

Wes

Great, thanks Wes. Can I share your expression code in this forum?

Yep! You’re looking at doing something like the below. If you want to create additional if-else logic at the field level, you just pass another function, but inside the field(). Hops this helps!

function(state){
if(conditions){

create(“Object_Name__c”,fields(

fields and relationships

),state);

}},

Hi Everyone, thanks for your help with this!

This will be really beneficial as we plan to run multiple conditional jobs in the near future.