Skip to main content

I’m trying to use the idea in this post to pull values when an account field is updated into a page that will be used to create a custom object, but am getting mixed results. Ultimate goal is to pull in values from a multi-select picklist from the account object, but for now, I’m just trying to understand what is happening.


Here’s a subset of Barry’s code from the post above.


skuid.snippet.registerSnippet('handleAccountChange', function(field, value) {        console.log(field.row);
var acctCity = field.model.getFieldValue(field.row, 'Account.BillingCity')
, acctCountry = field.model.getFieldValue(field.row, 'Account.BillingCountry')
, formulaValue = acctCity + ' ' + acctCountry;

// update the formula field with the new value
field.model.updateRow(field.row, 'TestFormula\_\_c', formulaValue);
});

Output of console.log(field.row) shows BillingCity and BillingCountry associated with the object


Here’s the code in my page:


skuid.snippet.registerSnippet('handleDefaultPkg', function(field, value) {        var acctCity = field.model.getFieldValue(field.row, 'Account\_\_r.BillingCity', true),
acctCountry = field.model.getFieldValue(field.row, 'Account\_\_r.BillingCountry', true),
acctCode = field.model.getFieldValue(field.row, 'Account\_\_r.Account\_ID\_\_c', true),
pkgDefault = acctCity + '-' + acctCountry + '-' + acctCode;

console.log(field.model);
console.log(pkgDefault);
// update the formula field with the new value
field.model.updateRow(field.row, 'Instructions\_\_c', pkgDefault);
});

Output of console.log(field.row) does not show BillingCity or BillingCountry. Only Account_ID__c is seen.


Final result of my version puts snull-null-ABC123] into the Instructions__c field.


Why are some fields from the object included/accessible and others not?

Hi Jared -

If I’m understanding what you are trying to do correctly, the likely source of your issue is that you do not have the BillingCity, BilingCountry, etc. fields specified in your search conditions on the Account Field in the field editor.  When “Searching” for a field, Skuid issues SOQL to retrieve the record values (e.g. Id, Name, etc.).  By default, it will only retrieve Id & Name.  If you need additional fields, you need to add these to the Search Fields of the field in the field editor.  You’ll also want to make sure that these same fields are added to the Model in the page for your custom object.  By ensuring the fields are in both of these places, you should start to see the data you expect.

One other thing - With “UI Only Fields” now available (they were not available when I wrote the code in the post you referenced), you might be able to achieve your end goal without writing any code at all.  By creating a UI Only FIeld on your Custom Object model, marking it Formula and writing the formula in there, you get automatic updates for free.  In other words, as the Account field changes, so will the resulting formula field.

Hope this helps!


Hi Barry,

Thanks for the explanation.  It worked after I added Billing City and Billing Country to the search fields.

The good news is that this also worked for what I was actually trying to accomplish, which was get values from a multi-select picklist from the account to load as the default selections on the skuid page.

Thanks again!


Awesome news Jared glad that did it for you!