I have a javascript snippet and an associated “on-error” action that work just fine when I preview my page inside of Salesforce. The “on-error” action should display a pop-up. But, when I test the page inside of the Community, the pop-up does not show up. My button just gets grayed out and nothing happens on the page. I thought this could be a browser pop-up issue, but other pop-ups inside the Community ARE working.
Any errors in console?
No errors, but I see different things in the console in internal SF vs. the Community.
Internal:
Community:
The Javascript is looking at the difference between today’s date (2018-04-12) and a date field (2018-04-02, in this case) to make sure they are greater than 18 years and throws an error if not.
Here’s what my Javscript looks like (I’m checking to see if a new Patient is less than 18 years old; if so, an alternate contact is required).
$ = skuid.$;
var Patient = skuid.$M(‘PatientAccount’),
thePatient = Patient.getFirstRow();
var bday = Patient.getFieldValue(thePatient, ‘PersonBirthdate’ );
var AltContact = Patient.getFieldValue(thePatient, ‘Alternate_Contact_Name__c’);
var override = Patient.getFieldValue(thePatient, ‘NoAlternateContact’);
var today = skuid.time.getSFDate(new Date());
var millisecondsperday = 24 * 60 * 60 * 1000;
var diff = (skuid.time.parseSFDate(today)-skuid.time.parseSFDate(bday))/ millisecondsperday / 365.2424;
console.log(today);
console.log(bday);
console.log(diff);
returnVal = true;
//Create your conditional statements
if ( AltContact === null && ( diff < 18 ) && override !== true ) {
returnVal = false;
}
return returnVal;
Does the Profile used in the community have access to all the fields in the models?
Yes. It’s just two fields - Alternate_Contact_Name__c and PersonBirthdate. I checked access for both. (Thanks for thinking about this, Pat!)
“returnVal = true;” should be “var returnVal = true;”
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.