Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

How to edit related entity in web form step

Posted on by Microsoft Employee

I have a web form that has two steps. Step 1's mode is Edit and targets entity A. Step 2's mode is also Edit and targets entity B. Entity B has a lookup to entity A.

How do I specify the record source to edit for step 2? The possible values I can see for Source Type are Result From Previous Step and Query String. It doesn't work when I use Result From Previous Step (I'm guessing because I don't have a previous step that reference Entity B). Do I have to use the Query String option and pass the ID of entity B record somehow? If this is the case, any suggestion for doing this?

Thanks,
Bernado

*This post is locked for comments

  • Claus_Opticloud Profile Picture
    Claus_Opticloud 5 on at
    RE: How to edit related entity in web form step

    Hi, I am trying to get this to work but can't. What is the formid/where do I get it?

  • Gaurav_Pandey09 Profile Picture
    Gaurav_Pandey09 195 on at
    RE: How to edit related entity in web form step

    Hi Ravi,

    I believe the entityBfield is a field on the entityB form that is storing the guid of the record. And formid is the id of the webform. Is my understanding right?

    Thanks,

    Gaurav

  • Gopinath Gurusamy Profile Picture
    Gopinath Gurusamy 125 on at
    RE: How to edit related entity in web form step

    Hi Gaurav,

    var entityB = null;

    $(document).ready(function () {

       entityB = $("#entityBfield").val();

       var url = $('#formid').attr('action');

       $('#formid').attr('action', url + '&did=' + entityB);

    });

    This should work.

  • Gaurav_Pandey09 Profile Picture
    Gaurav_Pandey09 195 on at
    RE: How to edit related entity in web form step

    Hi Gopi,

    Could you please share the JavaScript code that you used. I am also facing the same issue.

  • Suggested answer
    Gopinath Gurusamy Profile Picture
    Gopinath Gurusamy 125 on at
    RE: How to edit related entity in web form step

    ah perfect.

    I only appended the 'bId=[guid]' to the URL of the HTML.

    This was my mistake. I replaced the existing url with my new url. Now i appended my query string to the existing url. It works as expected.  Thanks for your help.

    Btw, I am using online version of portal.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to edit related entity in web form step

    Oh and by the way, I'm using the Community edition of CRM Portal (i.e. OnPrem) - although I doubt this is why it's not working for you.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to edit related entity in web form step

    Hey Gopinath,

    I also have the Start New Session on Load set to Yes, but I do not get the error you mentioned. I only appended the 'bId=[guid]' to the URL of the HTML <form> element. I did not update any of the existing query string params in the default URL. Is that what you did also?

    Is that error only occurring when you arrived on the entity B step? Or as soon as you enter the form?

  • Gopinath Gurusamy Profile Picture
    Gopinath Gurusamy 125 on at
    RE: How to edit related entity in web form step

    Hi Bernado,

    Thanks for your quick response.

    I tried the same approach. It is working.

    But when  Start New session on Load is enabled for the web page, it displays an error(The record couldn't be found). If I didn't enable this option, cache issue happens (whenever I open a record it goes to the last opened web form step instead of going to step 1)

    Did you observe the same behavior ? I need this option to be enabled should I pass the session id also to the url ?

    80823.Capture.PNG

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to edit related entity in web form step

    Hey Gopinath,

    I workarounded this issue with some JavaScript.

    I configured entity B step (step 2) as edit, and uses query string parameter as the source record ID. Here I specified 'bId' as the query string parameter name.

    In step 1 (entity A step), I added some JavaScript to the step. This script on load would get the ID of the related entity B record, and then modify the action attribute of the HTML <form> element to add 'bId=[entityBRecordId]' to the post URL. When the Next button is clicked, the updated URL is used to navigate to the next step and therefore passes entity B ID to step 2.

    Hope that helps :)

  • Gopinath Gurusamy Profile Picture
    Gopinath Gurusamy 125 on at
    RE: How to edit related entity in web form step

    Hi Bernado,

    I have similar kind of issue. How did you pass the id of entity B to edit form step ?

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans