web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Set field value using JScript

(0) ShareShare
ReportReport
Posted on by

Hi,

I am trying to set a field (new_attendanceguid) value to the ID of the current record using JScript but I do not have coding experience. Would someone be able to help with the complete code for this if it is even possible?

*This post is locked for comments

I have the same question (0)
  • KaeL Profile Picture
    224 on at

    Hi david_1 can you  provide what data/record you want to get? but  if you are trying to get the record/data of a field try to use this Xrm.Page.getAttribute("field_record").getValue() and if the field type is a lookup field try this Xrm.Page.getAttribute("field_record").getValue()[0].id, if you are trying to get the id of the entity try this Xrm.Page.data.entity.getId() and if you want to set the value of the id to the field (new_attendanceguid) you can use this 

    Xrm.Page.getAttribute("new_attendanceguid").setValue(field_record);

    or something like this

    getRecordID: function() {

    if (Xrm.Page.getAttribute("field_record").getValue()[0].id != null){

    var getRecord = Xrm.Page.getAttribute("field_record").getValue()[0].id;

    Xrm.Page.getAttribute("new_attendanceguid").setValue(getRecord );

    }

    },

    you can save this function on the form load.

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi David ,

    Are you going to update record primary GUID , if yes then you can not update record id using JavaScript as id field does not exists in the form or you can not add the field in the form.

    Here is some tutorial of some client side scripting basics , hope this helps.

    You can check below reference for available event in Dynamics CRM.

    https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/events

    If you are using V8.2 , please refer below -

    https://msdn.microsoft.com/en-us/library/jj602964.aspx

    For Dynamics CRM V9 you can check below reference -

    https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference

    https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/attributes/getvalue

    https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/attributes/setvalue

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans