Skip to main content

Notifications

Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

I am unable to getID and set the value in form

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

  • Charan Raju C R Profile Picture
    Charan Raju C R 3,155 Super User 2024 Season 1 on at
    RE: I am unable to getID and set the value in form

    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;

  • unbeatable Profile Picture
    unbeatable 365 on at
    RE: I am unable to getID and set the value in form

    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

  • unbeatable Profile Picture
    unbeatable 365 on at
    RE: I am unable to getID and set the value in form

    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);

                       }

                       } );

                   }

  • Charan Raju C R Profile Picture
    Charan Raju C R 3,155 Super User 2024 Season 1 on at
    RE: I am unable to getID and set the value in form

    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)?

  • Suggested answer
    Joe99 Profile Picture
    Joe99 20 on at
    RE: I am unable to getID and set the value in form

    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

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,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans