locked
Auto Populating Unit when selecting a product in Opportunity Product. RRS feed

  • Question

  • Hello Everyone,

                  I am using CRM 2011 and i am stuck in a issue where I want to fetch the unit when i select a product in opportunity product.

    How do i achieve it.

    With Thanks,

    Bilal Sayed.


    Bilal Sayed.
    Tuesday, March 22, 2011 2:42 PM

Answers

  • You will need to do a retrievemultiple call on the unit where the related attribute equals the guid of the current entity you are on.

    Here is a couple retrieve multiple examples in Jscript.

    http://mileyja.blogspot.com/2011/03/crm-2011-retrievemultiple-calls-in.html

    You can get the Guid for the entity on the form you are on using this:

    var GUIDvalue = Xrm.Page.data.entity.getId();

    I hope this helps!


    Jamie Miley
    http://mileyja.blogspot.com
    LinkedIn Profile
    Tuesday, March 22, 2011 2:58 PM
    Moderator
  • In addition, this should be done with a slight delay. During the OnChange Event handler, the Unit Lookup will remain readonly.

    function ProductOnChange_SetUOM() {   
       if (Xrm.Page.getAttribute("productid").getValue() != null) {
          // delay of 100ms, because uomid is readonly
        window.setTimeout("SetUomId()", 100); } }
    Wednesday, March 23, 2011 9:19 AM

All replies

  • You will need to do a retrievemultiple call on the unit where the related attribute equals the guid of the current entity you are on.

    Here is a couple retrieve multiple examples in Jscript.

    http://mileyja.blogspot.com/2011/03/crm-2011-retrievemultiple-calls-in.html

    You can get the Guid for the entity on the form you are on using this:

    var GUIDvalue = Xrm.Page.data.entity.getId();

    I hope this helps!


    Jamie Miley
    http://mileyja.blogspot.com
    LinkedIn Profile
    Tuesday, March 22, 2011 2:58 PM
    Moderator
  • In addition, this should be done with a slight delay. During the OnChange Event handler, the Unit Lookup will remain readonly.

    function ProductOnChange_SetUOM() {   
       if (Xrm.Page.getAttribute("productid").getValue() != null) {
          // delay of 100ms, because uomid is readonly
        window.setTimeout("SetUomId()", 100); } }
    Wednesday, March 23, 2011 9:19 AM