You need to sign in to do that
Don't have an account?
Cloud Atlas
Javascript Running but not updating
Hello ,
I have the below JScript as a button.. Everytime I am clicking it, the page refreshes but nothing changes..
Can some one point out what am is missing in there..
I am building a WF on this.. so field update is necessary...
Button is supposed to change the RT value from Claim to Risk and manipulate data in successive fields...
Any help is appreciated.
Thanks!
I have the below JScript as a button.. Everytime I am clicking it, the page refreshes but nothing changes..
Can some one point out what am is missing in there..
I am building a WF on this.. so field update is necessary...
Button is supposed to change the RT value from Claim to Risk and manipulate data in successive fields...
{!REQUIRESCRIPT("/soap/ajax/***/connection.js")} var a = false; if({!Case.Possible_Risk__c} != true) a = confirm('Are you sure you want to change this from a Claim to a Risk?'); var recordType = sforce.connection.query('select id, name from recordtype where sobjecttype=\'Case\' and name = \'US Risk\''); var recordTypeEMEA = sforce.connection.query('select id, name from recordtype where sobjecttype=\'Case\' and name = \'EMEA Risk\''); var records = recordType.getArray("records"); /* alert('Check records' + records); */ var recordsE = recordTypeEMEA.getArray("records"); /* alert('Check recordsE' + recordsE); */ if(a) { var newRecords = []; var c = new sforce.SObject("Case"); c.id = "{!Case.Id}"; c.Possible_Risk__c = true; // Checkbox on which my WF will depend on// c.Reason__c = 'Risk'; c.OwnerId = '{!$User.Id}'; /* alert('Inside IF, check for EMEA' + {!ISPICKVAL(Case.Region__c, 'EMEA')}); */ if ({!ISPICKVAL(Case.Region__c, 'EMEA')}) c.RecordTypeId = recordsE[0].Id; else c.RecordTypeId = records[0].Id; newRecords.push(c); result = sforce.connection.update(newRecords); window.location.reload(); }
Any help is appreciated.
Thanks!
1. On line 26, you are referring to recordsE[0] and there is no recordsE object, you have a records object so it should read:
c.RecordTypeId = records[0].Id;
2. Line 33 is a closing brace for the if statement on 13 which is commented out so you need to either comment out line 33 or remove it.
Are you using firebug or another JS tool to help you debug your JS? It can be very helpful in determining if your JS has errors along with console.log statements in your JS.