'On Error' action in Community

  • 1
  • Problem
  • Updated 7 months ago
  • In Progress
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.
Photo of Elissa Bradley

Elissa Bradley

  • 1,672 Points 1k badge 2x thumb

Posted 7 months ago

  • 1
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,704 Points 20k badge 2x thumb
Any errors in console?
Photo of Elissa Bradley

Elissa Bradley

  • 1,672 Points 1k badge 2x thumb
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;
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,704 Points 20k badge 2x thumb
Does the Profile used in the community have access to all the fields in the models?
Photo of Elissa Bradley

Elissa Bradley

  • 1,672 Points 1k badge 2x thumb
Yes.  It's just two fields - Alternate_Contact_Name__c and PersonBirthdate.  I checked access for both.  (Thanks for thinking about this, Pat!)
Photo of Stephen Sells

Stephen Sells, Official Rep

  • 16,856 Points 10k badge 2x thumb
"returnVal = true;" should be "var returnVal = true;"