Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

CRM 365: Cloning a custom entity record and Opening the cloned record automatically

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello

I have a requirement to clone a custom entity record and open the record (clone) automatically in a new window.

I know we can

- create a real time workflow to clone a record

- use the function openEntityForm to open the record in new window

But I am finding a way to see how can I open the cloned record automatically?

Will be helpful if anyone can advise me please?

Regards

B

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: CRM 365: Cloning a custom entity record and Opening the cloned record automatically

     you could create an additional lookup field, put it on the form, make it hidden, and populate it from the same workflow.

    How can i get the record id in the look up field and what shall i populate from the workflow?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: CRM 365: Cloning a custom entity record and Opening the cloned record automatically

    Hi Alex

    It worked thank you very much for your help.

    You have been very helpful and spent time in explaining the steps.

    Regards

    B

  • ashlega Profile Picture
    ashlega 34,477 on at
    RE: CRM 365: Cloning a custom entity record and Opening the cloned record automatically

    Add this to your script:

    function errorCallback()

    {

    }

    I asked you above, but, apparently, used wrong case.. (B vs b)

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: CRM 365: Cloning a custom entity record and Opening the cloned record automatically

    No it didn't call the alert that means it hasn't called the function.

    When I refreshed the record page it showed me this exception message, does it give any clue after seeing my code?

    "Uncaught ReferenceError: errorCallback is not defined"

    Regards

    B

  • ashlega Profile Picture
    ashlega 34,477 on at
    RE: CRM 365: Cloning a custom entity record and Opening the cloned record automatically

    Could you add an alert right at the beginning of that success callback function to confirm if it gets called?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: CRM 365: Cloning a custom entity record and Opening the cloned record automatically

    Hi Alex

    Thanks for your reply.

    I have made the changes it has moved a step forward.

    Now the lookup is getting populated on clicking the ribbon button but the record is not opening automatically :(

    Let me know if I am missing something pls?

    Regards

    B

  • ashlega Profile Picture
    ashlega 34,477 on at
    RE: CRM 365: Cloning a custom entity record and Opening the cloned record automatically

    Hi Babu,

      are you getting that "Workflow executed successfully" message?

      If yes, try calling refresh right after that alert - see below. I've also removed brackets which you put after openClonedEntityXYZ.. Did you define errorCallBack somewhere - I don't see it in your code? If not, add an empty function at least:

    function errorCallBack()

    {

    }

      

    function triggerCloneWorkflow()

    {

       Process.callWorkflow("9C3AB0D5-BC11-46A5-AFF3-303123ACBCFA",

       Xrm.Page.data.entity.getId(),

       function () {

           alert("Workflow executed successfully");

           Xrm.Page.data.refresh(true).then(openClonedEntityXYZ, errorCallback);

       },

       function () {

           alert("Error executing workflow");

       });

      

    }

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: CRM 365: Cloning a custom entity record and Opening the cloned record automatically

    Hi Alex

    When I click the ribbon button the workflow fires and created the record but the below code (refreshing the form) is not taking any effect hence the lookup field is not getting updated so the cloned record is not getting opened automatically.

    function triggerCloneWorkflow()

    {

       Process.callWorkflow("9C3AB0D5-BC11-46A5-AFF3-303123ACBCFA",

       Xrm.Page.data.entity.getId(),

       function () {

           alert("Workflow executed successfully");

       },

       function () {

           alert("Error executing workflow");

       });

      Xrm.Page.data.refresh(true).then(openClonedEntityXYZ(), errorCallback);

    }

    function openClonedEntityXYZ()

    {

     var clonedKeyDate = Xrm.Page.data.entity.attributes.get('xyz_clonedEntity');

     var windowOptions = {openInNewWindow: true};

     if(clonedKeyDate != null)

      Xrm.Utility.openEntityForm("xyz_entity", clonedKeyDate.getValue()[0].id, null, windowOptions );

    }

    Can you advise me please?

    Thanks

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: CRM 365: Cloning a custom entity record and Opening the cloned record automatically

    Hi Guys

    Thanks for your replies.

    I have created a ribbon button which will call the code below

    function triggerCloneWorkflow()

    {

    Process.callWorkflow("9C3AB0D5-BC11-46A5-AFF3-303123ACBCFA",

       Xrm.Page.data.entity.getId(),

       function () {

           alert("Workflow executed successfully");

       },

       function () {

           alert("Error executing workflow");

       });

    }

    When I click the button I am getting "Error executing workflow", is there anything that I am missing here?

    Regards

    B

  • ashlega Profile Picture
    ashlega 34,477 on at
    RE: CRM 365: Cloning a custom entity record and Opening the cloned record automatically

    Hi B,

     that should work, too.

     Although, I'm pretty sure process.js supports any type of workflows - it probably does not care that much since how you call the workflow is no different between real-time and async workflows.. What's happening on the server at that moment is different, though. For the real-time workflows they will start right away and your "client-side" will wait till the workflow has completed

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…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 231,313 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans