0

I have a custom button to create a new opportunity from a contact record. This button passes variables to prepopulate fields on the opportunity. I also have a roll-up field on the account that counts the number of opportunities. Is it possible to increment that roll-up field when passing it to the new opportunity?

For example, I want my Opportunity Name to be the Account name and the number of opportunities + 1, opp3={!Account.Name}{!Account.Opportunity_Count__c} + 1

If it's possible, what is the correct syntax?

  • Have you tried this- ‘opp3={!Account.Name & (Account.Opportunity_Count__c+1)}’ it might need some tweak to have null check. – Raul Nov 25 '17 at 18:17
  • I tried that and received an error. Error: Incorrect parameter type for operator '&'. Expected Text, received Number – MarvinM Nov 25 '17 at 18:27
  • opp3={!Account.Name & TEXT(Account.Opportunity_Count__c+1))} – cropredy Nov 25 '17 at 18:41
  • that did not work either. error: missing } – MarvinM Nov 25 '17 at 18:53
  • opp3={!Account.Name & TEXT(Account.Opportunity_Count__c+1)} – Raul Nov 25 '17 at 20:00
1

You can do this. I recommend that you use URLFOR to save yourself the headache of parameter encoding (which is, coincidentally, why your formula isn't working as you expected):

{!URLFOR($Action.Opportunity.New, null, [opp3=Account.Name & " " & 
    TEXT(Account.Opportunity_Count__c+1)], true)}

If you're in a formula that doesn't allow URLFOR, then make sure you properly encode your parameter:

/006/e?opp3={!Account.Name}%20{!Account.Opportunity_Count__c+1}

Note that "%20" is a "space" that's been encoded. If you put in a normal space (" "), the browser may not encode it correctly or transmit correctly, because " " is not allowed in a URL; the underlying protocol uses a " " to separate the values sent to the server, such as GET /index.html HTTP/1.1, which specifies the action ("GET"), the file to retrieve ("/index.html"), and the version of the protocol to use ("HTTP/1.1").

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.