locked
onLoad Script not saving data RRS feed

  • Question

  • I have a script that changes the format of the name field in this entity record. This is applied to onLoad and onSave of the form. (I have also tried it with only onLoad).

    The script runs, and when the form loads it changes the format of the name field as shown in photo. However, when I save and close the record it does not save the new name and reverts back to the previous name. 

    function designQueueName()
    {

    var versionNumber = "";
    var projectNumber = "";

    if (Xrm.Page.getAttribute("orbus_versionnumber").getValue()!=null)
    {
    versionNumber = Xrm.Page.getAttribute("orbus_versionnumber").getValue();
    }

    if (Xrm.Page.getAttribute("orbus_projectnumber").getValue()!=null)
    {
    projectNumber = Xrm.Page.getAttribute("orbus_projectnumber").getValue();
    }

    combined = 'Project No ' + projectNumber + ' | Version No. ' + versionNumber;
    // trim ends for spaces and pipe symbol
    combined = combined.replace(/^\s+\|/, "").replace(/\|\s+$/,"")
    Xrm.Page.getAttribute("orbus_name").setValue(combined);

    }

    there is also another onSave script running. I have already tried to disable this but did not fix above error. 

    function designQueueOnSave()
    {
    //Force Submit
    Xrm.Page.getAttribute("orbus_name").setSubmitMode("always");
    Xrm.Page.getAttribute("orbus_projectnumber").setSubmitMode("always");
    }

    Tuesday, November 18, 2014 6:30 PM

Answers

  • Hi Nicole,

    I used your script in one of my entity and it's running fine. There is either some plugin, workflow or javascript that is running and overwriting the name field.

    Make sure the project no and version number fields are single line of text.  Your Version no field and Project Number Fields are read only. From where you are getting these values. you need to chech that script also.


    Regards, Saad


    • Edited by Mohd Saad Wednesday, November 19, 2014 5:09 AM
    • Marked as answer by Nicole_CRM Wednesday, November 19, 2014 1:31 PM
    Wednesday, November 19, 2014 5:05 AM

All replies

  • Also realized that if I change name manually it will allow me to save and close but does not reflect change. 
    Tuesday, November 18, 2014 6:45 PM
  • hi,

    looks like the name of the record is getting overwritten. Could you alert the name in designQueueOnSave and see what the value is?.

    also JavaScript is client side. Any server side plugin or workflow will override this. Please check if there are any plugin or workflow changing this field?.

    regards

    Jithesh

    Tuesday, November 18, 2014 7:43 PM
  • I went through all of the field depencies to make sure. There are no workflows that update this field. I can not find any other scripts that reference this field besides the ones I outlined and do not see a plugin on this field.
    Tuesday, November 18, 2014 8:02 PM
  • Hi,

    Try to force submit in the onload function immediately after setting the value and check. If it doesn't work, for sure there is something which is modifying the value. Else, check the onsave function by adding some alerts. It should work.

    Regards,

    Gopinath.

    Wednesday, November 19, 2014 5:01 AM
  • Hi Nicole,

    I used your script in one of my entity and it's running fine. There is either some plugin, workflow or javascript that is running and overwriting the name field.

    Make sure the project no and version number fields are single line of text.  Your Version no field and Project Number Fields are read only. From where you are getting these values. you need to chech that script also.


    Regards, Saad


    • Edited by Mohd Saad Wednesday, November 19, 2014 5:09 AM
    • Marked as answer by Nicole_CRM Wednesday, November 19, 2014 1:31 PM
    Wednesday, November 19, 2014 5:05 AM