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?

3
  • What is the final URL you're trying to achieve? Dec 27, 2018 at 21:00
  • In the new page I just need to set a picklist value coming from the parent object.
    – lemdev
    Dec 27, 2018 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, 2018 at 2:06

1 Answer 1

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.

You must log in to answer this question.

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