If a user with a custom profile, called IB, clicks the button the "Submit Project Number Request" works correctly, however, if a different profile clicks the button I get the javascript error, expected expression, got')' .
Here is my code, which states, if the custom object is Engagements and the field IB M&A Engagement field is True on the IB record use the record type id for IB else use record type id for the other profiles. This works for the IB profile, but not for other profiles. Should I be using a different type of function other than an "if" function? I feel my error is in my if statement. I have truncated the id's for posting purposes.
if({!Engagements__c.IB_M_A_Engagement__c})
{
myEng.RecordTypeId = '0122.......';
} else {
myEng.RecordTypeId = '012j.....';
}
Any assistance would be very appreciated!!
8 个回答

+1 Deepak
Ideally Robin your IF statement should check if the field value comes back as null and handle things accordingly otherwise you may run into this error with other profiles too.If the profile doesn't have read access to that field, the javascript that actually renders is:
if()
{
myEng.RecordTypeId = '0122.......';
} else {
myEng.RecordTypeId = '012j.....';
}
if() will throw the error you're getting. You could change the JS to something like this:
var engagement = {!Engagements__c.IB_M_A_Engagement__c};
if(engagement != null && engagement == true)
{
myEng.RecordTypeId = '0122.......';
} else {
myEng.RecordTypeId = '012j.....';
}