Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Update values from a web resource

(1) ShareShare
ReportReport
Posted on by 12,081 Moderator

Hi all, 

I have a web resource and I want to update it's value from a web resource. I write following code which is not updating my value

<html>

<head>

<title> </title>

<script type="text/javascript" src="ClientGlobalContext.js.aspx"></script>

<script type="text/javascript">

function myFunction() {
debugger;
var x = document.getElementById("myText").value;
if(x == "VPA" ||x == "vpa" ){
var lookup = new Array();
lookup[0] = new Object();
lookup[0].name = "VPA";
lookup[0].id = "83D67CFE-09A1-E611-B7CD-005056C00008";
lookup[0].entityType ="aw_paymentmethod";
window.parent.opener.Xrm.Page.getAttribute("aw_paymentmethod").setValue(lookup);
//window.opener.parent.document.crmForm.all.aw_paymentmethod.DataValue= lookup;// It is giving me error
window.parent.opener.Xrm.Page.data.entity.save();
}
}

</script>

<meta charset="utf-8">

<body >

<form method="post" action="">

<fieldset>

<legend>Input Payment Method</legend>

<p>

<label>Payment Method</label>

<input id="myText" type="text">

</p>

</fieldset>

<button type="button" onclick="myFunction()">OK</button>

</form>

</body>

</html>

Thank you

*This post is locked for comments

  • Abdul Wahab Profile Picture
    Abdul Wahab 12,081 Moderator on at
    RE: Update values from a web resource

    Hi all

    I find the answer of my own Question

    <html>

       <head>

            <title> </title>

     <script type="text/javascript" src="ClientGlobalContext.js.aspx"></script>

     <script src="aw_SDK.REST.js" type="text/javascript"></script>

     <script src="aw_json2.js" type="text/javascript"></script>

     <script type="text/javascript">

                   function myFunction() {

    debugger;

    var x = document.getElementById("myText").value;

    if(x == "VPA" ||x == "vpa" ){

    var currentleadId = window.parent.opener.Xrm.Page.data.entity.getId();

    var opportunity = {};

    var lookup = new Array();

    var changes = {

    aw_PaymentMethod: {        

    Id: "83D67CFE-09A1-E611-B7CD-005056C00008", // Guid of the parent account

    LogicalName: "aw_paymentmethod"

    }

    }

    SDK.REST.updateRecord(

    currentleadId,

    changes,

    "Opportunity",

    function () {

    //writeMessage("The account record changes were saved");

    },

    errorHandler

    );

    }

    }

    function errorHandler(error) {

    alert(error.message);

    }

                 </script>

    <meta charset="utf-8">

    <body >  

     <form method="post" action="">

      <fieldset>

          <legend>Input Payment Method</legend>

          <p>

            <label>Payment Method</label>

            <input id="myText" type="text">

          </p>

        </fieldset>

     <button type="button" onclick="myFunction()">OK</button>

      </form>

    </body>  

    </html>

    thank you

  • Abdul Wahab Profile Picture
    Abdul Wahab 12,081 Moderator on at
    RE: Update values from a web resource

    Hi all

    From my point of view everything is correct but I don't know Why it is not updating my value ?

    Thank you

  • Abdul Wahab Profile Picture
    Abdul Wahab 12,081 Moderator on at
    RE: Update values from a web resource

    Hi all,

    No one is going to answer my Question.? too much strange that Question to me.

    Thank you

  • Abdul Wahab Profile Picture
    Abdul Wahab 12,081 Moderator on at
    RE: Update values from a web resource

    Hi all,

    No one is there to answer my Question ?

    thank you

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,409 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans