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 :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested Answer

I am unable to getID and set the value in form

(0) ShareShare
ReportReport
Posted on by 365

Hi Everyone, can anyone help me with this I am unable to set the value.

any help would be great.

6761.pastedimage1616736443016v1.png

I am using this id 

7127.pastedimage1616736638981v2.png

I have the same question (0)
  • Suggested answer
    Joe99 Profile Picture
    20 on at

    Is that an entity's out of the box HTML or is it your custom HTML?

    Can you not get that via formcontext or xrm.page? docs.microsoft.com/.../clientapi-form-context

  • Charan Raju C R Profile Picture
    7 Moderator on at

    Hi,

    Can I check if you are trying to set the value of a tag in HTML web resource (embedded on the form) from a javascript web resource (registered on the form)?

  • unbeatable Profile Picture
    365 on at

    Hi thanks for the reply

    i am unable to set value to field could please help me to find my error

    function ProductQuantity(context) {

                    debugger;

                    var formContext = context.getFormContext();

                    var tempProduct = formContext.getAttribute("msdyn_product").getValue();

                     if (tempProduct != null) {

                    var proid = tempProduct[0].id;

                    }

                    var FetchXML="<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>"+

                    "<entity name='msdyn_productinventory'>"+

                    "<attribute name='createdon' />"+

                    "<attribute name='msdyn_warehouse' />"+

                    "<attribute name='msdyn_unit' />"+

                    "<attribute name='msdyn_qtyonhand' />"+

                    "<attribute name='msdyn_product' />"+

                    "<attribute name='msdyn_reorderpoint' />"+

                    "<attribute name='msdyn_qtyonorder' />"+

                    "<attribute name='msdyn_qtyavailable' />"+

                    "<attribute name='msdyn_qtyallocated' />"+

                    "<attribute name='msdyn_productinventoryid' />"+

                    "<order attribute='msdyn_product' descending='true' />"+

                    "<filter type='and'>"+

                    "<condition attribute='msdyn_product' operator='eq' uiname='0423530172J' uitype='product' value='" + proid + "' />"+

                    "<condition attribute='msdyn_warehouse' operator='eq' uiname='NETS-Riff_mains' uitype='msdyn_warehouse' value='{25069A0A-F382-EB11-A812-000D3AAF0EA4}' />"+

                    "</filter>"+

                    "</entity>"+

                    "</fetch>";

                    FetchXML = "?fetchXml=" + encodeURIComponent(FetchXML);

                    debugger;

                     Xrm.WebApi.retrieveMultipleRecords("msdyn_productinventory", FetchXML).then(

                      function success(result) {

                       debugger;

                       if(result.entities.length>0){

                       var totalcount= result.entities[0].msdyn_qtyavailable;

              //var Pquantity=window.parent.document.getElementById("Tcount").value;

                       //Pquantity.innerHTML=totalcount;

                     formContext .getAttribute("new_test").setValue(totalcount);

                       }

                       } );

                   }

  • unbeatable Profile Picture
    365 on at

    yes I am using custom HTML through id am trying to display the result which I am getting through custom javascript as I have displayed above

  • Charan Raju C R Profile Picture
    7 Moderator on at

    Tag with id Tcount cannot be directly accessed from the javascript webresource registered to on the form. First we need to get access to HTML webreource and then to it's HTML tag. Try to use the below script to set tag value of HTML webresource from javascript webresource.
    WebResource_Sample is HTML webresource name which you can get from CRM form and suffix it with '_d'.

    var Pquantity = parent.document.getElementById("WebResource_Sample_d").childNodes[0].childNodes[0].contentDocument.getElementById("Tcount");
    Pquantity.innerHTML = totalcount;

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 > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
#ManoVerse Profile Picture

#ManoVerse 101

#2
Siv Sagar Profile Picture

Siv Sagar 93 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 66 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans