You need to sign in to do that
Don't have an account?
Matt Cooper 7
OnClick Javascript button to update status not working
I built out a custom button that should run some javascript to update a field value if certain conditions are met. However, when I test the button, the else clause always runs.
Any help on what is wrong with the javascript would be much appreciated:
Any help on what is wrong with the javascript would be much appreciated:
{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")} var agmt = new sforce.SObject("Apttus__APTS_Agreement__c"); agmt.Id = '{!Apttus__APTS_Agreement__c.Id}'; if('{!Apttus__APTS_Agreement__c.Apttus__Status__c}'== 'Internal Review'){ agmt.Apttus__Status__c = 'Other Party Review'; result = sforce.connection.update([agmt]); window.location.reload(); } else if('{!Apttus__APTS_Agreement__c.Apttus__Status__c}' == 'Other Party Review'){ alert('This agreement has already been sent for review'); } else if('{!Apttus__APTS_Agreement__c.Apttus__Status__c}' == 'Activated' || '{!Apttus__APTS_Agreement__c.Apttus__Status__c}' == 'Fully Signed' ){ alert('This agreement is fully signed'); } else{ alert('This agreement must first be sent for legal review'); }
All Answers
Have you create the custom button on the object 'Apttus__APTS_Agreement__c'. If yes, it should work as I cannot find any issue in the code.
If no, You need to query Apttus__APTS_Agreement__c fields to check in the if-else.
Let me know, if I can help you more.
Thanks,
Neetu
It came back with agmtid = undefined, status = blank, if statement result = false. I feel like this is all dependent on the agmt.id not setting, but not sure why it isn't linking to the record's id.
Just try by increasing the version and adding script for Apex. May be Apttus__APTS_Agreement__c object does not supported in previous versions. If you still not able to resolve, you can share your salesforce org login credentials, I will be able to look into it and help you.
Thanks,
Neetu
Hi Neetu,
Increasing the version didn't seem to help. What's interesting is if I replace agmt.id with
'{!Apttus__APTS_Agreement__c.Id}' in the alert, it shows the record's id. So for some reason it's not setting the agmt.id to the record's id with the agmt.Id = '{!Apttus__APTS_Agreement__c.Id}'; line. Also, do you have any idea why it would be able to read the id, but not the Apttus__Status__c field?
Sadly, our org has some very sensitive information in it and I can't give you access.
Thanks,
Matt