You need to sign in to do that
Don't have an account?
Karen Davis 1
Can I use an onclick javascript button to do what I want? And if so, how do I do it?
I am not a developer, but I am trying to figure out how to create a button and I've been sent here from the success forum. I have a button that will clone an existing record based on a stored record ID. It works fine, however, if that previous record field is blank (one doesn't exist yet) it errors out in a not very nice way. What I want to do is any of the following:
1) Disable the button if there is no previous record (stored in the field Account.LastExam_ID__c)
2) Create a cloned record if an ID exists or create a new record if one does not exist
3) If a record does not exist, at least give a nice error message and return them to the original page.
The url (which works) to create a clone is this:
/{!Account_LastExam_ID__c}/e?clone=1&CF00N54000000Px0Y={!Treatment__c.Name}&CF00N54000000Px0Y_lkid={!Treatment__c.Id}&retURL=%2F{!Treatment__c.Id}&RecordType={!IF( Treatment__c.ADA_Code__c ="191", "012540000004Nma", "012540000004NmV")}
The url (which works) to create a new record is this:
/a5U/e?CF00N54000000Px0Y={!Treatment__c.Name}&CF00N54000000Px0Y_lkid={!Treatment__c.Id}&retURL=%2F{!Treatment__c.Id}&RecordType={!IF( Treatment__c.ADA_Code__c ="191", "012540000004Nma", "012540000004NmV")}
I thougth I could make it work by creating a variable that held either "a5U" or the value of "Account_LastExam__c" and another one that held either a blank or "clone=1&" and inserting them into the code like this:
/{!Treatment__c.Clone_button_URL__c}/e?{!Treatment__c.Clone_button_URL_2__c}&CF00N54000000Px0Y={!Treatment__c.Name}&CF00N54000000Px0Y_lkid={!Treatment__c.Id}&retURL=%2F{!Treatment__c.Id}&RecordType={!IF( Treatment__c.ADA_Code__c ="191", "012540000004Nma", "012540000004NmV")}
But it doesn't work. The "clone=1&" doesn't come over correctly. It almost works. But it doesn't work. Any suggestions would be very welcome.
1) Disable the button if there is no previous record (stored in the field Account.LastExam_ID__c)
2) Create a cloned record if an ID exists or create a new record if one does not exist
3) If a record does not exist, at least give a nice error message and return them to the original page.
The url (which works) to create a clone is this:
/{!Account_LastExam_ID__c}/e?clone=1&CF00N54000000Px0Y={!Treatment__c.Name}&CF00N54000000Px0Y_lkid={!Treatment__c.Id}&retURL=%2F{!Treatment__c.Id}&RecordType={!IF( Treatment__c.ADA_Code__c ="191", "012540000004Nma", "012540000004NmV")}
The url (which works) to create a new record is this:
/a5U/e?CF00N54000000Px0Y={!Treatment__c.Name}&CF00N54000000Px0Y_lkid={!Treatment__c.Id}&retURL=%2F{!Treatment__c.Id}&RecordType={!IF( Treatment__c.ADA_Code__c ="191", "012540000004Nma", "012540000004NmV")}
I thougth I could make it work by creating a variable that held either "a5U" or the value of "Account_LastExam__c" and another one that held either a blank or "clone=1&" and inserting them into the code like this:
/{!Treatment__c.Clone_button_URL__c}/e?{!Treatment__c.Clone_button_URL_2__c}&CF00N54000000Px0Y={!Treatment__c.Name}&CF00N54000000Px0Y_lkid={!Treatment__c.Id}&retURL=%2F{!Treatment__c.Id}&RecordType={!IF( Treatment__c.ADA_Code__c ="191", "012540000004Nma", "012540000004NmV")}
But it doesn't work. The "clone=1&" doesn't come over correctly. It almost works. But it doesn't work. Any suggestions would be very welcome.
We have used a Javascript Button , Add Scipts on the top (Ajax Libraries and Scripts Version 36.0)
Then call a flow from that button
Flow-Create a flow and you can copy the value (Clone) and if there is no value you can display a graceful failure message and if there is a value copy it and create a new record and then you can also update the records with flows it self
Its declarative and easy to understand
Add the flow URL to the Button