I need to display the modified on in another text field which is multiple lines text field using javascript.
Criteria is there are two fields first is, option set in which has true and false and second is, multiple lines of text.
So using javascript i need to display the modified on data into second field when the value of first field is selected as yes.
And it can be run every time, so in the second text field add the new data of that time modified on into second field with previous one.
So, can anyone help me to do this using javascript?
*This post is locked for comments
Hi Sakti,
Please remove window.parent and try.
Thanks,
Shahbaaz
This is the code that i am recently used but it gives script error, so what can i do?
function onSave()
{
// Get Option Set Value
var isCheck = window.parent.Xrm.Page.getAttribute("new_caseesclated").getValue();
alert(isCheck);
if(isCheck == yes)
{
alert("insdie if");
//Retrieve the modified on value using current record id
var d = new Date();
var currentValue = window.parent.Xrm.Page.getAttribute("new_escalatedblog").getValue();
window.parent.Xrm.Page.getAttribute("new_escalatedblog").setValue(currentValue + "\n" + d.toString());
}
}
Hi,
I would think you need an onsave javascript that would be doing this:
var isCheck = Xrm.Page.getAttribute("FieldName").getValue();
if(isCheck)
{
var d = new Date();
var currentValue = Xrm.Page.getAttribute("MiltilineTextFieldName").getValue();
Xrm.Page.getAttribute("MiltilineTextFieldName").setValue(currentValue + "\n" + d.toString());
}
Although, maybe I'd rather have that done in a workflow/plugin..
Hello Shakti,
Try to write like below -
function onChangeOptionSet() { // Get Option Set Value var isCheck = Xrm.Page.getAttribute("FieldNAme").getValue(); if(isCheck) { //Retrieve the modified on value using current record id var recordid =Xrm.Page.data.entity.getId(); var modifiedon = null; var name = null; var req = new XMLHttpRequest(); req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/accounts("+recordid+")?$select=modifiedon,name", true); req.setRequestHeader("OData-MaxVersion", "4.0"); req.setRequestHeader("OData-Version", "4.0"); req.setRequestHeader("Accept", "application/json"); req.setRequestHeader("Content-Type", "application/json; charset=utf-8"); req.setRequestHeader("Prefer", "odata.include-annotations=\"*\""); req.onreadystatechange = function() { if (this.readyState === 4) { req.onreadystatechange = null; if (this.status === 200) { var result = JSON.parse(this.response); modifiedon = result["modifiedon"]; name = result["name"]; //Set field value Xrm.Page.getAttribute("MiltilineTextFieldName").setValue(modifiedon); } else { Xrm.Utility.alertDialog(this.statusText); } } }; req.send(); } }
Mohamed Amine Mahmoudi
83
Super User 2025 Season 1
Community Member
54
Victor Onyebuchi
6