Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Answered

Pass return value from a Web resource to Success Callback

Posted on by 25

How to Pass return value from a Web resource to Success Callback in Xrm.Navigation.navigateTo?

function success(returnValue) {
          // do stuff with return value
},
  • Sudharshini Profile Picture
    Sudharshini 25 on at
    RE: Pass return value from a Web resource to Success Callback

    Thanks, I have used local storage.

  • Verified answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Pass return value from a Web resource to Success Callback

    The only easy way of doing it I found was usage of sesionStorage/localStorage. If you want to see the way I do it - I have a post/video scheduled for this week where I will demonstrate how I do it. So if you don't want to miss it - subscribe to my blog and youtube channel.

  • Marco.P Profile Picture
    Marco.P 2,405 on at
    RE: Pass return value from a Web resource to Success Callback

    Can't you create a bool field called "isfromwebresource" with default false and then updated the multiline field and isfromwebresource to true and handle the logic in the plugin ?

    like if (isfromwebresource) return

    else // do the classic plugin logic

  • Sudharshini Profile Picture
    Sudharshini 25 on at
    RE: Pass return value from a Web resource to Success Callback

    Yes, I have tried. It returns null.

    It's a multi line text field.

  • Marco.P Profile Picture
    Marco.P 2,405 on at
    RE: Pass return value from a Web resource to Success Callback

    Did you try window.parent.Xrm.Page.getAttribute("field name").setValue(value)?

    which type of field it is?

  • Sudharshini Profile Picture
    Sudharshini 25 on at
    RE: Pass return value from a Web resource to Success Callback

    We would definitely need the plugin to trigger.

    If we find any options to update the field using DOM getAttribute methods, the service call can be avoided.

  • Sudharshini Profile Picture
    Sudharshini 25 on at
    RE: Pass return value from a Web resource to Success Callback

    Is there any option to set the crm field value from modal webresource using DOM?

    I have tried many options with getAttribute and it did not work.

  • Marco.P Profile Picture
    Marco.P 2,405 on at
    RE: Pass return value from a Web resource to Success Callback

    Since it appears to be not possible to return any value, you need to think out of the box.

    Does the logic of that plugin apply only in this scenario ? If so you can choose to use a Custom Workflow Activity and trigger that instead of your plugin .

    Do you need the plugin to trigger or you can avoid it by playing with the depth?

    Those are questions that only you can ask and answer.

  • Sudharshini Profile Picture
    Sudharshini 25 on at
    RE: Pass return value from a Web resource to Success Callback

    That's what I'm doing right now. Created a hidden field and passing the value from web resource through a webapi call.

    As soon as the data is saved in the hidden field, i'm triggering a plugin.

    Since its happening asynchronously in the backend, we are facing some issues when the plugin throws any exception.

    So I wanted to try in this way.

  • Suggested answer
    Marco.P Profile Picture
    Marco.P 2,405 on at
    RE: Pass return value from a Web resource to Success Callback

    Hi,

    according to MS official documentation it yet can't be done with web resource (results :

    https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/xrm-navigation/navigateto

    Return Value

    Returns a promise. The value passed when the promise resolves is dependent on the target:

    inline: Promise resolves right away, and does not return any value.

    dialog: Promise resolves when the dialog is closed. An object is passed only if the pageType = entityRecord and you opened the form in create mode. The object has a savedEntityReference array with the following properties to identify the entity record created:

    entityType: The logical name of the entity.

    id: A string representation of a GUID value for the record.

    name: The primary attribute value of the record displayed or created.

    Which type of value do you need to return? Can't you make and update on a hidden field on form storing that value from the web resource?

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans