Hi All,
As the title says I am having issues with cloning a record.
I am using an ajax call to achieve the former as it allows me to get the new record id and open the entity form automatically. It all works fine except for when I try to maintain a field value to the same as the original record. This field is an autonumber field which uses a plugin that I have written and it has been working great so far.
What I am try to achieve is a mechanism of revision (Name and all the data within the clone record will be the same as the original, apart for a revision number which will be incremented every time a revision is done)
Every time I create a new record it gets a unique number assigned to it (which is fine in case of a "brand new" one) but as soon as I try to clone it maintaining the old number then I get an internal server error from the ajax.
I know I could bypass the plugin execution by putting a dummy yes/no field and check it's value inside it to decide what to do. But before proceeding with it I would like to know if there is a better and cleaner way to achieve this.
Thanks for you time
Christian
*This post is locked for comments
Hi all
I have found the cause to this problem and it was due to the fact that the field had a character limitation. At the time of testing I was using a string which exceeded the limit, hence why the error.
Schoolboy error from my side.
Thank you for you time
Hi ChristianCRM91,
I think you should have create new field which store previous unique number for the reference.
Let me know if you require something more.
Thanks
Regards,
AW
Hi Erik thanks for your response,
I have tried using both sync and async ajax with no luck.
The scenario you described is slightly different:
I have a record like the following:
Name = Order123 (autogenerated - this means that the next time I create an order it will be "Order124" - this is done via plugin)
RevisionNo = 1 (it defaults to one at the time of creation)
When I press "Revise" I want to get:
Name = Order123(This should not be incremented)
RevisionNo = 2 (whatever the previous revision plus 1)
The problem I am facing is that if I create a record without specifying the autonumber, the plugin automatically assigns the next available one (and this is not what I want in this case, I want this to happen on creation of brand new records)
If I, however, specify the number to be the same or whatever else (if the field is not null) then I get the internal server error
Let's say it's an order record and you have
Name = Order123
RevisionNo = 1
Customer = Customer Co
if you clone it sans the Revision no, it should end up as
Name = Order 123
RevisionNo = null
Customer = Customer Co
and then the RevisionNo is set by a synchronous oncreate plugin, correct?
I don't see why this would throw an error. Are you sure it's this field causing it?
What does the reponse from the call say? Is the ajax call synchronous or async?
André Arnaud de Cal...
292,160
Super User 2025 Season 1
Martin Dráb
230,962
Most Valuable Professional
nmaenpaa
101,156