1

Can we use formula field in javascript button? im getting an error "Incorrect parameter type for function 'or()'. Expected Boolean, received Text".

Account_Inactive__c is formula field on contact object which returns "Active" or "Inactive" if the checkbox on account field is checked and viceversa

if( {!or(Account.Inactive_del__c, false)} ) {
    alert('You cannot create a new opp for an Inactive account.');
} 
else if( {!or(Contact.Inactive__c,false)} ) {
    alert('You cannot create a new opp for an Inactive contact.');
}
else if( {!or(Contact.Account_Inactive__c,active)} ) {
    alert('You cannot create a new opp for an Inactive contact.');
}
else
{
    window.top.location.href = "{!URLFOR($Action.Opportunity.New, null, ["retURL"="/"&NULLVALUE(Contact.Id, Account.Id), "00N40000002Gafd"=Account.Location__c, "opp3"=Account.Name&" "&"-","opp4_lkid"=Account.Id,"conid"=Contact.Id], true)}";
}
3
  • Hi, Admin_BA. It looks like the code you've written here isn't quite right. This code, as is, should result in a JavaScript compile error, not a merge field error. Could you please doublecheck your code?
    – sfdcfox
    May 11, 2016 at 19:32
  • Updated full code, the first 2 conditions work but the third one is throwing error
    – Admin_BA
    May 11, 2016 at 19:34
  • Iam geting error "Field active does not exist. Check spelling"
    – Admin_BA
    May 11, 2016 at 19:36

1 Answer 1

3

The word "active" should be "false", just the same as the previous two entries. OR always takes Boolean values, true or false, or fields that are checkboxes, or comparisons (<, >, !=, =, <>, etc) that compare to true or false.

2
  • But Account_Inactive__c is formula field (IF(Account.Inactive_del__c,"Inactive", "Active")) that updates value "Active" or "Inactive" how can i use true or false? the formula field is text type
    – Admin_BA
    May 11, 2016 at 19:46
  • 2
    @Admin_BA That was probably important to mention. In that case, you actually need to use quotes: {!Contact.Account_Inactive__c="Inactive"}. Using = will compare two texts and return a Boolean, as you need.
    – sfdcfox
    May 11, 2016 at 19:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .