Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Insert the data of modified on field in another text field

(0) ShareShare
ReportReport
Posted on by 940

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

  • Suggested answer
    Shahbaaz Ansari Profile Picture
    Shahbaaz Ansari 6,205 on at
    RE: Insert the data of modified on field in another text field

    Hi Sakti,

    Please remove window.parent and try.

    Thanks,

    Shahbaaz

  • RE: Insert the data of modified on field in another text field

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

    }
    }

  • ashlega Profile Picture
    ashlega 34,477 on at
    RE: Insert the data of modified on field in another text field

    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..

  • Suggested answer
    gdas Profile Picture
    gdas 50,089 on at
    RE: Insert the data of modified on field in another text field

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


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

Announcing Our 2025 Season 1 Super Users!

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

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans