Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Convert items in Option Set into Value (Currency)

Posted on by 250

Hi,

I have an optionset (Probability %) that has values 10, 25, 50, 75 and my opportunity form has a weighted opp value field which basically takes the (Total Value * probability)/100.

How do I change the value in the Probability option set into a currency type (Total Value and opp value are both currency) and perform the calculation?

Thanks

*This post is locked for comments

  • SharjeelButt Profile Picture
    SharjeelButt 250 on at
    RE: Convert items in Option Set into Value (Currency)

    @Guido: Thank you much! It worked!

    @Karth: Thank you for your input. That code will def guide me to use it appropriately in future cases!

  • SharjeelButt Profile Picture
    SharjeelButt 250 on at
    RE: Convert items in Option Set into Value (Currency)

    My code is:

    function calculateTotal()

    {

    var soft = Xrm.Page.getAttribute("new_softwarerevenue").getValue();

    var serv = Xrm.Page.getAttribute("new_servicerevenue").getValue();

    var dev = Xrm.Page.getAttribute("new_developerrevenue").getValue();

    var oth = Xrm.Page.getAttribute("new_otherrevenue").getValue();

    var tot = Xrm.Page.getAttribute("new_totalestimatedrevenue");

    var add = soft+serv+oth+dev;

    if(soft !=null || serv != null || dev != null || oth != null)

    {

    tot.setValue(add);

    }

    else {return;}

    var probability = Xrm.Page.getAttribute("new_probability").getText();

    if (probability != "")

    {

      var percent = parseFloat(probability);

      var oppValue = tot * percent/100;    

      Xrm.Page.getAttribute("new_opportunityvalue").setValue(parseFloat(eval(oppValue)));

    }

    }

  • SharjeelButt Profile Picture
    SharjeelButt 250 on at
    RE: Convert items in Option Set into Value (Currency)

    This is the error I get even with replacing the code:

     

  • Suggested answer
    Karth Profile Picture
    Karth on at
    RE: Convert items in Option Set into Value (Currency)

    Replace this...

    Xrm.Page.getAttribure("new_finalvalue").setValue(finalValue);

    with this..

    Xrm.Page.getAttribute("new_finalvalue").setValue(parseFloat(eval(finalValue)));

    Let me know if this works.

    Cheers,

    Karth

  • SharjeelButt Profile Picture
    SharjeelButt 250 on at
    RE: Convert items in Option Set into Value (Currency)

    Hi Guido,

    Thanks for the response. However, I'm getting the error that I need to enter a value between the range of -1,000,000,000.0000 to 1,000,000,000.0000,

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans