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

Passing variable / parameter to external web resource

(0) ShareShare
ReportReport
Posted on by 30

Hi there

I have successfully created a Web Resource in our Sales Trial which displays an external web page on the Account screen.

When calling the web resource I need to pass a variable so a query can be run on the page and the correct data returned.

EG pass account code which will be looked up in our database, the returning data will be displayed on the page and shown in the Account screen.

Am I using the correct terminology? and what methods are available to achieve this please?

Could I pass the parameter in the URL? If so how to dynamically add the parameter?

This article references the Custom Data Parameter column in the web resource dialogue, but where is that located?

Sample: Pass multiple values to a web resource through the data parameter (model-driven apps) - Power Apps | Microsoft Docs

Most grateful for your assistance.

Paul

I have the same question (0)
  • Community Member Profile Picture
    on at

    Hi dynaman365,

    How do you call the web resource, type address in the bowser or open it with Client API?

  • dynaman365 Profile Picture
    30 on at

    Hi Steve - thanks for your reply

    I've inserted a web resource onto the form and successfully called an external html page which is great.  I need to pass the account name for example when calling the external page. I've just discovered if I double click on the form in the editor I get the below image:

    I've ticked the box to pass identifiers as parameters. I now need to check to see what is being passed and display it back to prove that I'm receiving them on the external html page.  Any pointers to achieve that?

    pastedimage1642759139690v1.png

  • Community Member Profile Picture
    on at

    Hi dynaman365,

    A quick question:  Where are your account name from? Is it a static value or it comes from the Account entity's form of the CRM?

  • dynaman365 Profile Picture
    30 on at

    Hi Steve

    Yes I'd like to take the account name or another field from the account entities form and pass it in the URL.  Is that possible?

    Kind regards

  • dynaman365 Profile Picture
    30 on at

    I've managed to pass some static variables in the URL this morning. Now I need to figure out how to pass a variable, like the account name or some other value.

  • Verified answer
    Community Member Profile Picture
    on at

    Hi dynaman365,

    You can get form context in the web resource, and then get your account name from the Account's from. Please refer to this blog:

    https://carldesouza.com/how-to-use-formcontext-in-a-web-resource-in-dynamics-365-power-apps/

  • dynaman365 Profile Picture
    30 on at

    Hi Steve - great link. Some very helpful content there.

    I dont think this helps me achieve what I need in this instance, but perhaps I've misunderstood.

    What I need to do is somehow pass a parameter along with the call to the external web resource EG 

    www.mywebsite.com/?accountName=ABC123

    The account code will then be looked up in our database and our page loaded into a form on the account page.

    Does that seem feasible?

  • dynaman365 Profile Picture
    30 on at

    If it is not possible to pass a parameter along with the call to the external web resource, is it possible to define the parameter using one web resource, then create an action to call the external web resource using that defined parameter?

    EG, look up the account name "ABC123", use script "callExternalWebResource.js" to call another web resource "mysite.com/externalWebResource.html"

  • Verified answer
    Community Member Profile Picture
    on at

    Hi dynaman365,

    Please try this:

    1. Get the account name from the Account's form in your html type web resource, as shown in previous blogs.

    2. Then send ajax request with your URL www.mywebsite.com/?accountName=[account name got from step1] in your web resource. Reference: Access external web service using HTML Web Resource - Microsoft Dynamics CRM Forum Community Forum

    3. Finally get the data returned from ajax request and add it your web resource.

  • dynaman365 Profile Picture
    30 on at

    Hi Steve

    Thanks so much for your assistance on this one.  I have finally got something working!  on_load of the Accounts form it runs an html web resource which contains some javascript which calls an external web page and appends the accountID to the url.  The external page then looks up relevant meta data related to this record and displays it in the web resource.

    I think you are correct that it requires an Ajax request as currently the web page doesn't actually appear until the page is reloaded.

    In case it helps anyone else this is the code I used:

     

    var myVarName = formContext.getAttribute("requiredFieldName").getValue();
    
    var url = "www.example.com/?data="   myVarName;
    
    var tag = document.createElement("object");
    tag.setAttribute( "type", "text/html");
    tag.setAttribute( "data", url );
    tag.setAttribute( "width", "600px");
    tag.setAttribute( "height", "600px");
    console.log( tag );
    document.body.appendChild( tag );

    The key was formContext.getAttribute to get the table field required from the form.

    I then used some javascript to call the web resource and build it into an HTML page.

    Kind regards

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 171 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 83

#3
Jimmy Passeti Profile Picture

Jimmy Passeti 50 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans