locked
set contract service level via jscript CRM 2011 question RRS feed

  • Question

  • Hi, when we create a new contract from a contract template, we need to set the service level of the contract to match the name of the contract template selected.  System derives the contract level for the contract from the Template but we don't want to set it that way.

    say we have the following contract templates 

    Company 8x5 Support  

    Company 24x7 Support 

    The optionsets for the Contract Service Level in the Contract Form are:

    8x5 Support who's optionset code is 1 

    24x7 Support whos optionset code is 2

    Now, when the user creates a new contract of type "Company 24x7 Support", the service level should be set to "24x7 Support". I tried to write a jscript for Contract Form Create event and try to read the "contracttemplateid" lookup name but am not successful. Appreciate if someone could point me in the right direction.  


    • Edited by CRM elite Monday, April 2, 2012 8:13 PM
    Monday, April 2, 2012 8:11 PM

Answers

  • hi,

    you can do by javascript

    on ONLoad of Contract 

    function OnLoad()
    {
    // this field is look up field of contract template it as name ex "24 x 5"
    if(Xrm.Page.getAttribute("contracttemplateid").getValue() != null)
    {
    if(Xrm.Page.getAttribute("contracttemplateid").getValue()[0].name=="24 x 5")
       Xrm.Page.getAttribute("new_service").setValue(parseInt(1)); //optionset with value 1 & labe 24 * 5
    else
    Xrm.Page.getAttribute("new_service").setValue(parseInt(2)); 
    }
    
    }


    Khaja Mohiddin
    http://www.dynamicsexchange.com
    http://about.me/KhajaMohiddin

    • Proposed as answer by Seepath Tuesday, April 3, 2012 2:49 PM
    • Unproposed as answer by Seepath Tuesday, April 3, 2012 2:49 PM
    • Marked as answer by CRM elite Tuesday, April 3, 2012 2:51 PM
    Monday, April 2, 2012 11:11 PM

All replies

  • hi,

    you can do by javascript

    on ONLoad of Contract 

    function OnLoad()
    {
    // this field is look up field of contract template it as name ex "24 x 5"
    if(Xrm.Page.getAttribute("contracttemplateid").getValue() != null)
    {
    if(Xrm.Page.getAttribute("contracttemplateid").getValue()[0].name=="24 x 5")
       Xrm.Page.getAttribute("new_service").setValue(parseInt(1)); //optionset with value 1 & labe 24 * 5
    else
    Xrm.Page.getAttribute("new_service").setValue(parseInt(2)); 
    }
    
    }


    Khaja Mohiddin
    http://www.dynamicsexchange.com
    http://about.me/KhajaMohiddin

    • Proposed as answer by Seepath Tuesday, April 3, 2012 2:49 PM
    • Unproposed as answer by Seepath Tuesday, April 3, 2012 2:49 PM
    • Marked as answer by CRM elite Tuesday, April 3, 2012 2:51 PM
    Monday, April 2, 2012 11:11 PM
  • Thanks a lot. I missed on one thing - ie. I put getvalue instead of getValue. I would need to enable the intellisense. 
    Tuesday, April 3, 2012 2:51 PM