locked
Set Value of a field to be the same as another field on form RRS feed

  • Question

  • Basic question I know but I have searched and can't find solution. I just keep getting stuff on filtered lookups.

    My question is this, is it possible to populate a lookup field with the same value in another field when the form is loaded? I have an OWNER field on the form which populates automatically when the form opens on creation of a new record. I also have another field on the form which is called Introducer. This is also a lookup to the same USER table as OWNER. All I want is for the "Introducer" field to automatially populate when the form opens on create, to be the same value as the OWNER.

    For those that are interested :) this is where we have bookers creating appointments for other sales people. When the record is created, they are automatically the OWNER but during the booking process, they change the OWNER to be the sales person carrying out the appointment. If I could get the "Introducer" field to default to the same value in the OWNER field then we keep the information on which booker booked the appointment. I know I could populate the Introducer field after the record is saved using workflow by setting the "Introducer" field to being the same as the "Created By" field however there may be occassions when this is done retrospectively by Temp Staff so wouldn't always be true.

    Hope all of that makes sense and hope some-one out there can help. Many thanks. Anita

    Wednesday, July 21, 2010 9:58 AM

Answers

  • Hi Anita,

    I think you should be able to do it with below code , remember to check field names properly

    var lookupData = new Array();
    //Create an Object add to the array.
       var lookupItem= new Object();
    //Set the id, typename, and name properties to the object.
       lookupItem.id = crmForm.all.ownerid.DataValue[0].id;

       lookupItem.typename = 'systemuser';
       lookupItem.name = crmForm.all.ownerid.DataValue[0].name;

    // Add the object to the array.
       lookupData[0] = lookupItem;
    // Set the value of the lookup field to the value of the array.
       crmForm.all.Introducerid.DataValue = lookupData;


    Mahain
    Wednesday, July 21, 2010 10:13 AM
    Moderator

All replies

  • Hi Anita,

    I think you should be able to do it with below code , remember to check field names properly

    var lookupData = new Array();
    //Create an Object add to the array.
       var lookupItem= new Object();
    //Set the id, typename, and name properties to the object.
       lookupItem.id = crmForm.all.ownerid.DataValue[0].id;

       lookupItem.typename = 'systemuser';
       lookupItem.name = crmForm.all.ownerid.DataValue[0].name;

    // Add the object to the array.
       lookupData[0] = lookupItem;
    // Set the value of the lookup field to the value of the array.
       crmForm.all.Introducerid.DataValue = lookupData;


    Mahain
    Wednesday, July 21, 2010 10:13 AM
    Moderator
  • Thank you Mahain, that worked an absolute treat!
    Wednesday, July 21, 2010 10:48 AM