locked
Tie two field in two different forms CRM 2011 RRS feed

  • Question

  • Hi,

    I am trying to get the information from a field in one form to another field in another form:

    Form 1:

    Project hours

    Form 2:

    Project Hours available

    I want the field in form 2 show the same number that we have in form 1

    Thanks,

    Tuesday, December 16, 2014 3:56 PM

All replies

  • Are they the same entity?

    If they are, you should be able to use the same field on both forms but make the field on form 2 read only perhaps.

    If they're not, then it gets a bit harder. Something like a call to the REST EndPoint when form 2 loads to get the data added in form 1.

    Tuesday, December 16, 2014 4:16 PM
  • I am fine if they are same fields, I want to show the number in the form in the second form :\
    Tuesday, December 16, 2014 4:44 PM
  • The thing is, the field does not show in the other form.

    So :

    Form 1:

    Project hours

    Form 2:

    It does show different fields, but not project hours under the Field Explorer!!

    Tuesday, December 16, 2014 4:50 PM
  • The 2 entities need to have a a parent/child relationship.  Then in the customizations, open the relationship between the entities, and then go to mappings.  You need to have a mapping set from the field on the parent or source to the child or target.  You can create a new mapping at this point if necessary.

    Once that is confirmed or set and published, when you create the child record from the parent record, the fields that are mapped from the parent will populate the mapped fields on the child.

    Note that if you create the child record from outside the parent record, the mapped fields will be blank because you won't have a source parent record that the information can be taken from.

    If you are seeing data populating that is different than what is in the parent, you either have a bad mapping or there may be jscript populating the fields.


    Jason Peterson

    Tuesday, December 16, 2014 8:55 PM
  • Hi Adey,

    If these two fields are in two entities, you need to create a relationship between these two entities.

    Then, you can write a JS function to update the related field from another entity.You can use

    XrmServiceToolkit to update a record.

    After that, put this function in onsave event or field onchange event.

    To update a record, you can try REST or SOAP function in XrmServiceToolkit.

    Rest sample:

    var account = {};
                account.Name = "Updated Account Name";
                  account.Address1_AddressTypeCode = { Value: 3 };            account.Address1_City = "Sammamish";
                account.Address1_Line1 = "123 Maple St.";
                account.Address1_PostalCode = "98074";
                account.Address1_StateOrProvince = "WA";
                account.EMailAddress1 = "someone@microsoft.com";
    
                XrmServiceToolkit.Rest.Update(
                    accountId,
                    account,
                    "AccountSet",
                    function () {
                        equals(true, true, "The record should have been updated.");
                    },
                    function (error) {
                        equal(true, false, error.message);
                    },
                    false
                );
    

    Soap sample:

    var updateContact = new XrmServiceToolkit.Soap.BusinessEntity("contact", contactId);
                updateContact.attributes["firstname"] = "Diane";
                updateContact.attributes["lastname"] = "Lopez";
                updateContact.attributes["donotpostalmail"] = null;
                updateContact.attributes["familystatuscode"] = { value: 2, type: "OptionSetValue" }; // Married
    
                var updateResponse = XrmServiceToolkit.Soap.Update(updateContact);
    

    For more information, please refer to Rest Functions and Soap Functions.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, December 17, 2014 6:20 AM