locked
price list default value RRS feed

  • Question

  • Hi,

     

    I have a requiremet where I need to set up a default price list on the orderproduct. Can anyone please suggest how would I be able to do that.

     

    Thanks.

    Wednesday, July 28, 2010 2:00 PM

Answers

  • try below code, rememeber to change bold fields

    /Create an array to set as the DataValue for the lookup control.
    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 = '{GUID of price list}';
       lookupItem.typename = 'pricelevel';
       lookupItem.name = 'name of pricelist';
    // Add the object to the array.
       lookupData[0] = lookupItem;
    // Set the value of the lookup field to the value of the array.
       crmForm.all.pricelist.DataValue = lookupData;


    Mahain
    • Proposed as answer by HIMBAPModerator Thursday, July 29, 2010 12:02 PM
    • Marked as answer by help23 Thursday, July 29, 2010 12:55 PM
    Wednesday, July 28, 2010 2:17 PM
    Moderator
  • Hi.

    You should insert valid identifier of pricelist into line

    lookupItem.id = '{pricelevelid}';

    like

    lookupItem.id = '{2E689F4C-D80A-42A1-82BF-B85F743DF1CF}';

     

    Error occurs because you haven't inserted correct identifier of pricelist.


    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    • Marked as answer by help23 Thursday, July 29, 2010 12:56 PM
    Thursday, July 29, 2010 12:38 PM
    Moderator
  • //Create an array to set as the DataValue for the lookup control.
    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 = '{8F57C186-4F80-DF11-AAB3-00155D160223}';
       lookupItem.typename = 'pricelevel';
       lookupItem.name = 'Primary Price List';
    // Add the object to the array.
       lookupData[0] = lookupItem;
    // Set the value of the lookup field to the value of the array.
       crmForm.all.pricelevelid.DataValue = lookupData;


    Try to change it to following:

    if (crmForm.FormType == 1)//this will work only on Create form

    {

    var lookupData = new Array();
       var lookupItem= new Object();
       lookupItem.id = '{8F57C186-4F80-DF11-AAB3-00155D160223}';
       lookupItem.typename = 'pricelevel';
       lookupItem.name = 'Primary Price List';
       lookupData[0] = lookupItem;
       crmForm.all.pricelevelid.DataValue = lookupData;

    }


    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    Thursday, July 29, 2010 1:56 PM
    Moderator

All replies

  • you should be able to set it through JS just like as Lookup ???

     


    Mahain
    Wednesday, July 28, 2010 2:09 PM
    Moderator
  • crmForm.all.pricelist.DataValue='Primary';

    this does not work :(/

    Wednesday, July 28, 2010 2:12 PM
  • try below code, rememeber to change bold fields

    /Create an array to set as the DataValue for the lookup control.
    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 = '{GUID of price list}';
       lookupItem.typename = 'pricelevel';
       lookupItem.name = 'name of pricelist';
    // Add the object to the array.
       lookupData[0] = lookupItem;
    // Set the value of the lookup field to the value of the array.
       crmForm.all.pricelist.DataValue = lookupData;


    Mahain
    • Proposed as answer by HIMBAPModerator Thursday, July 29, 2010 12:02 PM
    • Marked as answer by help23 Thursday, July 29, 2010 12:55 PM
    Wednesday, July 28, 2010 2:17 PM
    Moderator
  • crmForm.all.pricelist.DataValue='Primary';

    this does not work :(/


    This doesn't work because pricelist field is lookup. Check this url .


    Truth is opened the prepared mind

    My blog (english)
    Мой блог (русскоязычный)
    Wednesday, July 28, 2010 2:18 PM
    Moderator
  • Thank You Mahin. The script works so that it populated the price list but when I try to save the form it gives me an error saying that 'An error has occured.Contact you system Admin'. The forms loads without an error so dont know why is giving this error.

     

    Thanks for your help.

    Thursday, July 29, 2010 11:34 AM
  • Are you sure that you've inserted correct identifier into lookupItem.id?

    Can you paste your script here?


    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    Thursday, July 29, 2010 11:36 AM
    Moderator
  • It would have complaine if i had not put the correct identifiers. The script that I used is as follows.

     


    //Create an array to set as the DataValue for the lookup control.
    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 = '{pricelevelid}';
       lookupItem.typename = 'pricelevel';
       lookupItem.name = 'Primary Price List';
    // Add the object to the array.
       lookupData[0] = lookupItem;
    // Set the value of the lookup field to the value of the array.
       crmForm.all.pricelevelid.DataValue = lookupData;

    Thursday, July 29, 2010 12:37 PM
  • Hi.

    You should insert valid identifier of pricelist into line

    lookupItem.id = '{pricelevelid}';

    like

    lookupItem.id = '{2E689F4C-D80A-42A1-82BF-B85F743DF1CF}';

     

    Error occurs because you haven't inserted correct identifier of pricelist.


    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    • Marked as answer by help23 Thursday, July 29, 2010 12:56 PM
    Thursday, July 29, 2010 12:38 PM
    Moderator
  • Can you please confirm that you have used value GUID instead of pricelevelid ???

    lookupItem.id = '{pricelevelid}';

     


    Mahain
    Thursday, July 29, 2010 12:40 PM
    Moderator
  • Thank you Andriy. It is working now :-D.
    Thursday, July 29, 2010 12:55 PM
  • It is working but now another error is comin up

    When I try to add existing products, it is not letting me do that. It gives an erroe saying that' You have change the pricelist. Please save the order form before adding products'.

    I did sacve the list before adding products but does not work:((((((((((. helpppppp pleaseeeeeeeeee.

    Thursday, July 29, 2010 1:00 PM
  • Can you paste your onload code here?

    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    Thursday, July 29, 2010 1:08 PM
    Moderator
  • //Create an array to set as the DataValue for the lookup control.
    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 = '{8F57C186-4F80-DF11-AAB3-00155D160223}';
       lookupItem.typename = 'pricelevel';
       lookupItem.name = 'Primary Price List';
    // Add the object to the array.
       lookupData[0] = lookupItem;
    // Set the value of the lookup field to the value of the array.
       crmForm.all.pricelevelid.DataValue = lookupData;
    Thursday, July 29, 2010 1:50 PM
  • //Create an array to set as the DataValue for the lookup control.
    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 = '{8F57C186-4F80-DF11-AAB3-00155D160223}';
       lookupItem.typename = 'pricelevel';
       lookupItem.name = 'Primary Price List';
    // Add the object to the array.
       lookupData[0] = lookupItem;
    // Set the value of the lookup field to the value of the array.
       crmForm.all.pricelevelid.DataValue = lookupData;


    Try to change it to following:

    if (crmForm.FormType == 1)//this will work only on Create form

    {

    var lookupData = new Array();
       var lookupItem= new Object();
       lookupItem.id = '{8F57C186-4F80-DF11-AAB3-00155D160223}';
       lookupItem.typename = 'pricelevel';
       lookupItem.name = 'Primary Price List';
       lookupData[0] = lookupItem;
       crmForm.all.pricelevelid.DataValue = lookupData;

    }


    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    Thursday, July 29, 2010 1:56 PM
    Moderator
  • Thank You Andriy, it is working now but why was it giving the error.

    Thursday, July 29, 2010 2:07 PM
  • Because your script was triggered every time you open a form and changes the value of pricelist. System doesn't understand that pricelist field was updated with the same value.

    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    Thursday, July 29, 2010 2:11 PM
    Moderator
  • Thank Yoy Andriy. It was really helpful:).
    Thursday, July 29, 2010 2:17 PM