Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Record cloning / copying

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

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

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Record cloning / copying

    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

  • Suggested answer
    Abdul Wahab Profile Picture
    Abdul Wahab 12,077 Super User 2024 Season 1 on at
    RE: Record cloning / copying

    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

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Record cloning / copying

    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

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Record cloning / copying

    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?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,160 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,962 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans