2

I'm trying to set a picklist value in URLFOR.

I have a custom button and when the button is pressed the following javascript is executed:

window.parent.open("{!URLFOR( $Action.Custom_Object__c.New,null,[CF00M0N00000OpQRx = Account.Name, CF00NK0000001jyxH = {!URLENCODE(TEXT(Account.Schedule__c))}, CF00N2a000000b34C = Account.Custom_Number_Field __c])}", "_self");

In the first scenario:
CF00NK0000001jyxH = ''
I receive the following error:

Error: Field Account.Schedule__c is a picklist field. Picklist fields are only supported in certain functions.

In the second scenario:
CF00NK0000001jyxH = Account.Schedule__c
I receive the following error:

Error: Field Account.Schedule__c is a picklist field. Picklist fields are only supported in certain functions.

In the third scenario:
CF00NK0000001jyxH = TEXT(Account.Schedule__c)
I receive the following error:

Error: Field Account.Schedule__c is a picklist field. Picklist fields are only supported in certain functions.

In the forth scenario:
CF00NK0000001jyxH = {!URLENCODE(TEXT(Account.Schedule__c))}
I receive the following error:

Error: Syntax error

Could you please advise how to set a picklist value in URLFOR function?

  • What is the final URL you're trying to achieve? – codeyinthecloud Dec 27 '18 at 21:00
  • In the new page I just need to set a picklist value coming from the parent object. – lemdev Dec 27 '18 at 21:13
  • N.B. - the CF.... fieldnames, if new to the sandbox, may not be the same as you promote into other orgs. – cropredy Dec 28 '18 at 2:06
2

Do not put a merge field inside a merge field. As you have it now, you have this:

{! ... {! ... } ... }

This will confuse the compiler and result in the last error you received.

You also shouldn't need URLENCODE-- everything inside of [] is taken care of for you automatically.

As near as I can tell, this should work:

window.parent.open(
    "{!URLFOR(
        $Action.Custom_Object__c.New,
        null,
        [
            CF00M0N00000OpQRx=Account.Name, 
            CF00NK0000001jyxH=TEXT(Account.Schedule__c), 
            CF00N2a000000b34C=Account.Custom_Number_Field __c
        ]
    )}", 
    "_self");

I've added the newlines for clarity, but they're certainly not necessary.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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