problem in window.openr()

Pregunta problem in window.openr()

  • 5. května 2012 19:05
     
     

    hi

    i work with crm4, when i use this code in onloade of second form, fields doesnt fill with primform fields

    if (crmForm.FormType == 1)
    {
     // Check to confirm that the window.opener is present.
     if (window.opener)
     {
      // Get the values of the parent form.
      var oParentCrmForm = window.opener.document.all.crmForm;
       
      // Check that you obtained the values of the parent form and
      // that the parent form is an account.
      if (oParentCrmForm && oParentCrmForm.ObjectTypeCode == 1)
      {
       // Get the name of the account.
       var sAccountName = oParentCrmForm.all.name.DataValue;
           
       // Set the default value of the task subject to
       // include a reference to the related account.
       crmForm.all.parent_name.DataValue = "account: " + sAccountName;
      }
     }
    }

Všechny reakce

  • 5. května 2012 22:16
     
      Obsahuje kód

    If it's just the Account Name you need, you could just get the name from the Regarding Lookup reference on the Task:

    if (crmForm.FormType == 1) {
        var regardingObject = crmForm.all.regardingobjectid.DataValue;
        var regardingType = regardingObject[0].typename;
    
        // Check to confirm that it is regarding an account
        if (regardingType == "account") {
            // Get the name of the account.
            var sAccountName = regardingObject[0].name;
    
            // Set the default value of the task subject to
            // include a reference to the related account.
            crmForm.all.parent_name.DataValue = "account: " + sAccountName;
        }
    }

    Here's more information about getting the lookup data:
    http://www.magnetism.co.nz/blog/nathan/10-05-28/Retrieving_Data_from_Lookup_Fields.aspx

    Hope that helps!

    -Paul