Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

javascript code for multiply two field

Posted on by Microsoft Employee

I want to multiply two field as below:

function multiply()

{
var val1 = Xrm.Page.getAttribute(‘new_tax′).getValue();
var val2 = Xrm.Page.getAttribute(‘baseamount′).getValue();

if(val1==null)return;
if(val2==null)return;

var result = val1*val2;
Xrm.Page.getAttribute(‘tax’).setValue(result);
}

unfortunately I meet an error

'multiply' is undefined.

*This post is locked for comments

  • Suggested answer
    ganeshm Profile Picture
    ganeshm on at
    RE: javascript code for multiply two field

    follow this link ,in case you need hint in calculated field.

    www.powerobjects.com/.../calculated-fields-in-dynamics-crm-2015

    And remember every field after its creation is read only.only things that can editable is the display name.

  • Suggested answer
    Gopalan Bhuvanesh Profile Picture
    Gopalan Bhuvanesh 11,397 on at
    RE: javascript code for multiply two field

    You have to use a new calculated field where you are going to populate the result of this multiplication of

    new_tax and baseamount

  • Suggested answer
    ganeshm Profile Picture
    ganeshm on at
    RE: javascript code for multiply two field

    yes whenever you create a new field after the field creation you cant edit the field type.

    so after creating a new calculated field click edit and add your conditions

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: javascript code for multiply two field

    I have to fill 'new_tax' manual and when I Create it as calculated field,it become read only and should fill automatically.

  • ganeshm Profile Picture
    ganeshm on at
    RE: javascript code for multiply two field

    Created field(existing field) cannot be convert to calculated field.so try create a new field and use it

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: javascript code for multiply two field

    I cant add and use simple field in action of calculated field.

  • Gopalan Bhuvanesh Profile Picture
    Gopalan Bhuvanesh 11,397 on at
    RE: javascript code for multiply two field

    Click Edit Library and find out the the function is available.

    JavascriptFormOnload.PNG

  • ganeshm Profile Picture
    ganeshm on at
    RE: javascript code for multiply two field

    Well try to use "debugger;" in ur js and check it loaded in the form .

    Still facing the same error better to use the oob features by changing the 'tax' field as calculate field type.you can perform the same operation in them.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: javascript code for multiply two field

    Please check if the web resource where you write your javascript function is added to the form. Also please make sure that the form is published.

    using F12 debugging tool, make sure that the javascript resouces is loaded and the function is available. Keeping F12 window open clears the cache automatically.

    Jithesh

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