web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Pass return value from a Web resource to Success Callback

(0) ShareShare
ReportReport
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
},
I have the same question (0)
  • Suggested answer
    Marco.P Profile Picture
    2,405 on at

    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?

  • Sudharshini Profile Picture
    25 on at

    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.

  • Marco.P Profile Picture
    2,405 on at

    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
    25 on at

    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.

  • Sudharshini Profile Picture
    25 on at

    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.

  • Marco.P Profile Picture
    2,405 on at

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

    which type of field it is?

  • Sudharshini Profile Picture
    25 on at

    Yes, I have tried. It returns null.

    It's a multi line text field.

  • Marco.P Profile Picture
    2,405 on at

    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

  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    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.

  • Sudharshini Profile Picture
    25 on at

    Thanks, I have used local storage.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 108 Super User 2025 Season 2

#2
Jimmy Passeti Profile Picture

Jimmy Passeti 50 Most Valuable Professional

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 49 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans