function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
E_rockE_rock 

Variables in Button Code.

I have created a button on the Contact Object whcih will create a new Case and prepolulate many fields of the case.  I have logic in the code that looks to see if it's one reocrd type, create a Case with record type1.  Otherwise, create a case with record type2.  I am now trying to fill a picklist field on the Case with a specific value based upon a couple of variables which exist on the Account.  For some reason, it appears that I cannot accuratley put a condition whcih exists on the account?

 

&FieldID={!Case(Account.Field1__c ,
"Value1",(If(Account.Field2__c=True,"1","2")),
"Value2",(If(Account.Field2__c=True,"1","3"))"") }

 

I know the sytax is partially correct, becasue if I substuitute Account.Field1__c with Contact.Field1__c I see better resutls, but I still need to act upon a value that is in Account.Field2__c.  Can this be accomplished in basic button coding or is the only way to reference an account field with Apex or Java?

 

Any help would be appreciated.

 

rockchick322004rockchick322004

@E_rock, you can reference account fields from a contact record.  I did a simple Execute JavaScript type of button on the Contact object, on the detail page, with an alert, using a checkbox field to test:

 

alert ("Hello {!IF( Account.Test_Checkbox__c, "yes", "no")}");

 

[note that you can use =true in the IF function if you want, but you do not need to - it is implied]

 

One thing that might be happening is that the formula functions in the button evaluate on the server, so all values need to be known at the time the detail record is displayed to the user.

 

Also, what are the last two ""s representing?

 

What are you using to save the new Case record to the database?