locked
CRM 2011 Question- Rating field in Opportunity having condition following by Estimated Revenue(javascript) RRS feed

  • Question

  • Hi, im a newbee on crm 2011's javascript. Just a quick question.

    I have a custom entity which is Estimated Revenue in Opportunity. ( i don't use the OOTB) and a Rating which is a Picklist.( contain "moderate", "very important")

    so, my Rating's value is depending how much value that Estimated Revenue input.

    Eg : <=50000000 should be "moderate" in Rating.

    My code is onSave in Form Properties.

    my sample code as below, i didnt return any error in this code but it just didnt work :( please please help...i need any blog and advise from all the expertises out there :) thanks so much !

    function getEstToRating() {

    var EstAmount = Xrm.Page.data.entity.attributes.get("new_estrevenue");
    var ratingtype = Xrm.Page.data.entity.attributes.get("opportunityratingcode");
    var EstimatedAmountValue = EstAmount.getValue();
    var ratingvalue = ratingtype.getValue();

    if (EstimatedAmountValue<=50000000){
    ratingtype.getValue==3;
    }
    }

    Friday, July 6, 2012 8:28 AM

Answers

  • Hi,

    I believe you should replace

    ratingtype.getValue==3;

    with

    ratingtype.setValue(3);

    Also, the statement  var ratingvalue = ratingtype.getValue(); appears to be of no use in this code snippet.

    Hope this helps.

    Regards,

    Sven


    • Proposed as answer by Sven Moens Friday, July 6, 2012 1:04 PM
    • Marked as answer by jk1982 Monday, July 9, 2012 7:57 AM
    Friday, July 6, 2012 12:57 PM

All replies

  • Hi,

    I believe you should replace

    ratingtype.getValue==3;

    with

    ratingtype.setValue(3);

    Also, the statement  var ratingvalue = ratingtype.getValue(); appears to be of no use in this code snippet.

    Hope this helps.

    Regards,

    Sven


    • Proposed as answer by Sven Moens Friday, July 6, 2012 1:04 PM
    • Marked as answer by jk1982 Monday, July 9, 2012 7:57 AM
    Friday, July 6, 2012 12:57 PM
  • Hi,

    I believe you should replace

    ratingtype.getValue==3;

    with

    ratingtype.setValue(3);

    Also, the statement  var ratingvalue = ratingtype.getValue(); appears to be of no use in this code snippet.

    Hope this helps.

    Regards,

    Sven



    thanks so much Sven :)
    Monday, July 9, 2012 7:57 AM