You need to sign in to do that
Don't have an account?
Kurt A Brimberry
Custom JavaScript Button not Working when Looking Up Custom Field
Hello. I have a custom List Button that calls some onClick Javascript. The button works for all but the first argument, and I can't seem to wrestle this to the ground. We have 4 Account record types, and 4 matching Contact records types. When you create a new contact (from the Account related list) on an account, I want to skip the record type slection page entirely, since the Contact's record type is related to the Account's in a 1:1 fashion.
To do this, I created a custom formula field on the Account with the developer name for the Record Type. Then I wrote this JS. It works for 3 of the 4, but for End User it fails. Any Thoughts? Thanks in advance!
To do this, I created a custom formula field on the Account with the developer name for the Record Type. Then I wrote this JS. It works for 3 of the 4, but for End User it fails. Any Thoughts? Thanks in advance!
{!REQUIRESCRIPT("/soap/ajax/39.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/39.0/apex.js")} var agmt = new sforce.SObject("Account"); agmt.Id = '{!Account.Id}'; var agmtStats = sforce.connection.query("SELECT Account_Record_Type_for_Flows__c FROM Account WHERE id = '{!Account.Id}'"); records = agmtStats.getArray("records"); var agmtStat = records[0].Account_Record_Type_for_Flows__c; if(agmtStat == 'End User'){ alert('System Out'); } else if(agmtStat == 'Competitor'){ window.open('/003/e?retURL={!Account.Id}&accid={!Account.Id}&RecordType=0120j0000000EZh&ent=Contact '); } else if(agmtStat == 'Distributor'){ window.open('/003/e?retURL={!Account.Id}&accid={!Account.Id}&RecordType=0120j0000000EZX&ent=Contact '); } else if(agmtStat == 'Production Partner'){ window.open('/003/e?retURL={!Account.Id}&accid={!Account.Id}&RecordType=0120j0000000EZc&ent=Contact'); } else{ alert('Please Send Ticket to Helpdesk'); }