1
  {!IF( {!AND(Legal_Contract__c.Parent_Company_LC__c = "Company A",  Legal_Contract__c.Approval_Status_LC__c = "Approved")}, URLFOR("/apex/dsfs__DocuSign_CreateEnvelope",null, [sId=Legal_Contract__c.Id,ecId="a1Kn0000000AMMAEA4"]), 
        {!IF( {!AND(Legal_Contract__c.Parent_Company_LC__c = "Company B",  Legal_Contract__c.Approval_Status_LC__c = "Approved")}, URLFOR("/apex/dsfs__DocuSign_CreateEnvelope",null, [sId=Legal_Contract__c.Id,ecId="a1Kn0000000AMM9EAO"]),
        null
        )})}

2 Questions:

  1. Getting a syntax error, but not sure why.
  2. How do I stop this button from working if it doesn't meet the condition? I put the null in there, but now sure if that will do the trick. It would be nice to have a popup or alert message explaining why, but don't think that is possible in lightning.

Updated code, which addresses question 1. Question 2 still an issue:

{!IF( 
AND(Legal_Contract__c.Parent_Company_LC__c = "Company A", ISPICKVAL(Legal_Contract__c.Approval_Status_LC__c, "Approved")), 
URLFOR ("/apex/dsfs__DocuSign_CreateEnvelope",null, [sId=Legal_Contract__c.Id,ecId="a1Kn0000000AMMAEA4"]), 

IF( 
AND(Legal_Contract__c.Parent_Company_LC__c = "Company B", ISPICKVAL(Legal_Contract__c.Approval_Status_LC__c, "Approved")), 
URLFOR("/apex/dsfs__DocuSign_CreateEnvelope",null, [sId=Legal_Contract__c.Id,ecId="a1Kn0000000AMM9EAO"]), 

null)) 
}
1

The main issue is that you have multiple binding tags {!...} in the statement.

I have removed them here:

{!IF( AND(Legal_Contract__c.Parent_Company_LC__c = "Company A",  Legal_Contract__c.Approval_Status_LC__c = "Approved"), URLFOR ("/apex/dsfs__DocuSign_CreateEnvelope",null, [sId=Legal_Contract__c.Id,ecId="a1Kn0000000AMMAEA4"]), 
    IF(AND(Legal_Contract__c.Parent_Company_LC__c = "Company B",  Legal_Contract__c.Approval_Status_LC__c = "Approved")}, URLFOR("/apex/dsfs__DocuSign_CreateEnvelope",null, [sId=Legal_Contract__c.Id,ecId="a1Kn0000000AMM9EAO"]),null)
  )
}

Also, question 2... as you can't disable a button like this, make it reload this page. So instead of null, put in the current record id eg /abcn0000000YEHAAA

  • Oh!!! This is a regular button that you place on a Lightning layout. I thought you were making a component and I was pretty confused. – Caspar Harmer Feb 28 at 20:27
  • 1
    I would say... as you can't disable a button like this, make it reload this page. So instead of null, put in the current record id eg '/abcn0000000YEHAAA' – Caspar Harmer Feb 28 at 20:29
  • Edited answer to reflect new understanding. – Caspar Harmer Feb 28 at 20:33
  • Another solution is to use global action. I did this and it basically disabled the button. – HUBBY0716 Feb 28 at 21:13
  • Excellent! Of course, you can't use a global action in every situation. – Caspar Harmer Feb 28 at 22:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.