Hi all
I create a Web resource as shown below
I add a button and open this Web page through the button. I add a button using ribbon workbench.
When I click to this button. It opens this form to me as shown below
I need this text box value to update my form's method field . What can I do to fulfill my requirement?
My Form's method field is shown below
Thank you
*This post is locked for comments
Hi all,
I find my answer own.
<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
Hi all
I write the following code on me web resource but it does not give any effect to my opportunity form. It is not updating aw_paymentmethod value on the form. Before and running this script form has no change. Please suggest me Where I am wrong.?
<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);
}
}
</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>
Hi
Use the below code
In that ticker symbol, use your opportunity field
<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;
window.parent.opener.Xrm.Page.getAttribute("tickersymbol").setValue(x);
}
</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>
For this case:
"As you know when we close opportunity as won, save button is disabled. I need to work on this OK button."
Yup, you need to trigger onsave programmatically.
Or you can do: Update from odata then refresh the form.
Thanks.
Hi Abdul,
Mentioned before, you can refer that link to get the current attribute value.
Thank you.
Hi Aileen Gusni
How can I get current record from the form and pass it to this web resource and then get the value from this web resource and query to the database?
Thank you
Hi Aileen Gusni
As you know when we close opportunity as won, save button is disabled. I need to work on this OK button.
Thank you
Hi Aileen Gusni
What do you mean by "If the field is the same entity form where by you put your web resource" ?
I write following HTML to make my form
<!DOCTYPE html><html lang="en"><head>
<title>formDemo.html</title>
<script type="text/javascript" src="ClientGlobalContext.js.aspx"></script>
<script type="text/javascript">
function ABC() {
debugger;
var form = document.forms[0];
var context = GetGlobalContext();
var attrVal = window.parent.document.crmForm.<Attribute Name>.value;
// Your code for your functionality }
</script>
<meta charset="UTF-8">
</head>
<body>
<form>
<fieldset>
<legend>Input Payment Method</legend>
<p>
<label>Payment Method</label>
<input id="myText" type="text">
</p>
</fieldset>
<button type="button">OK</button>
</form>
</body></html>
which is look like as shown
When I click on Ok button it will update my method field on form which is on opportunity. This my desired. Please help me.
Thank you
Hi Abdul,
If the field is the same entity form where by you put your web resource
You can refer here:
crmjavascripts.blogspot.com/.../how-to-get-crm-entity-attribute-value.html
To Update, you can use also the same method, but using set value, instead of getvalue()
It is same as the standard JS but you just need this one:
var Xrm = window.parent.Xrm;
To let the code in web resource understand who Xrm is.
community.dynamics.com/.../howto-html-js-webresources
But it needs to trigger onsave js to update or ask the user to hit onsave to commit it manually based on user request.
Or..you can use odata to update or you can use custom action.
Hope this helps.
Thanks
Hi Clement
When I close my entity as won at that time I need this all. How can I get this text box value and query it to database to update my value.
Thank you
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156