locked
Auto populating Order pricelist RRS feed

  • Question

  • Hi guys,

    I know this has been posted a fair bit and I have come up with the following code that I am using.  My aim is to have an Order > Price List field populated with our "Whole Sale" price list when an order is created.

    I am currently using this:

        var value = new Array();
        value[0] = new Object();
        value[0].id = '{D23B208A-39A6-E111-A6F5-6CF049B2440B}';
        value[0].name = 'Test - SBSA - Wholesale';
        value[0].entityType = "Orders";
        Xrm.Page.getAttribute('pricelevelid').setValue(value);
    

    When I start a new Order it displays the price list as follows:

    I have a feeling it's to do with the ID. any help would be appreciated, thanks

    ZK


    Have a good day.

    Tuesday, March 26, 2013 6:21 AM

Answers

  • Try updating this line in your JavaScript:

    value[0].entityType = "pricelevel";
    

    Then of course verify the GUID you've chosen is in fact the GUID of the price list record you are trying to reference like Paul suggests.


    Jason Lattimer
    My Blog -  Follow me on Twitter -  LinkedIn


    Tuesday, March 26, 2013 11:14 PM
    Moderator
  • Yeah so the value that you are setting is the Price List value, nevermind that it is on an Order. When setting the lookup for Price List, the entityType needs to be the logical name for the value that you are setting, which in this case is the Price List logical name, "pricelevel".

    This is so that when CRM reads the value you are setting, it knows that the value is a reference to a Price List record, and not some other entity in the system. The name is simply used to be displayed in the lookup field on the form, and the id is used to know which Price List record to link to.

    The image in my first reply correctly shows where to get the values for the Price List lookup you are setting.

    Paul


    If my response helped you find your answer please show your thanks by taking the time to "Mark As Answer" and "Vote As Helpful".

    Twitter LinkedIn Facebook Blog Magnetism

    • Proposed as answer by Paul Nieuwelaar Wednesday, March 27, 2013 12:53 AM
    • Marked as answer by Fultz Wednesday, March 27, 2013 1:04 AM
    Wednesday, March 27, 2013 12:53 AM

All replies

  • The entityType value should be "pricelevel", as that is the entity logical name of the lookup you are setting (Price List in this case).

    And as long as the id/name are correct that should work fine. If in doubt you can open that price list record, and get the id parameter from the URL. The name should just be the name of the price list.

    Hope that helps

    Paul


    If my response helped you find your answer please show your thanks by taking the time to "Mark As Answer" and "Vote As Helpful".

    Twitter LinkedIn Facebook Blog Magnetism



    Tuesday, March 26, 2013 7:05 AM
  • Hi Paul,

    I think my explanation of my requirements was a bit too vague.  When I created an Order, I am trying to auto fill the "Price List" field on the Orders form (see image below), i'm pretty sure my code is correct and I have double checked the ID, but when I create a new Order, the "Price List" field is displayed as that of my first post.


    Have a good day.

    Tuesday, March 26, 2013 10:40 PM
  • Try updating this line in your JavaScript:

    value[0].entityType = "pricelevel";
    

    Then of course verify the GUID you've chosen is in fact the GUID of the price list record you are trying to reference like Paul suggests.


    Jason Lattimer
    My Blog -  Follow me on Twitter -  LinkedIn


    Tuesday, March 26, 2013 11:14 PM
    Moderator
  • Yeah so the value that you are setting is the Price List value, nevermind that it is on an Order. When setting the lookup for Price List, the entityType needs to be the logical name for the value that you are setting, which in this case is the Price List logical name, "pricelevel".

    This is so that when CRM reads the value you are setting, it knows that the value is a reference to a Price List record, and not some other entity in the system. The name is simply used to be displayed in the lookup field on the form, and the id is used to know which Price List record to link to.

    The image in my first reply correctly shows where to get the values for the Price List lookup you are setting.

    Paul


    If my response helped you find your answer please show your thanks by taking the time to "Mark As Answer" and "Vote As Helpful".

    Twitter LinkedIn Facebook Blog Magnetism

    • Proposed as answer by Paul Nieuwelaar Wednesday, March 27, 2013 12:53 AM
    • Marked as answer by Fultz Wednesday, March 27, 2013 1:04 AM
    Wednesday, March 27, 2013 12:53 AM
  • Hi Paul,

    Thanks for the help and the detailed explanation. changing that 1 line of code resolved the issue.

    cheers,

    XK.


    Have a good day.

    Wednesday, March 27, 2013 1:06 AM