Skip to main content

Notifications

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 958

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
    6,211 on at
    RE: Insert the data of modified on field in another text field

    Hi Sakti,

    Please remove window.parent and try.

    Thanks,

    Shahbaaz

  • Shakti Singh Rajput Profile Picture
    958 on at
    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
    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
    50,091 Moderator 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 the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 54

#3
Victor Onyebuchi Profile Picture

Victor Onyebuchi 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans