locked
how to solve this error? RRS feed

  • Question

  • // if cost changes,it will calculate resell price
    function new_cost_onchange() 
    {
        //Script to Calculate resell price
    
        //Resell=Cost+((Markup*Cost)/100)
        var markup;
        var cost;
        //read markup
        if (crmForm.all.new_markup != null) {
    
            markup = Xrm.Page.getAttribute(new_markup).getValue();
    
        }
        //read cost
        if (crmForm.all.new_cost != null) {
            cost = Xrm.Page.getAttribute(new_cost).getValue();
        }
        //Calculate Resell
        var Resell = cost + ((markup * cost) / 100);
        Xrm.Page.getAttribute(new_resellprice).setValue(Resell);
    }
    
    //if markup chamges,it will calculate resell price
    function new_markup_onchange() 
    {
        
        //Resell=Cost+((Markup*Cost)/100)
        var markup;
        var cost;
        //read markup
        if (crmForm.all.new_markup != null) 
        {
    
            markup = Xrm.Page.getAttribute(new_markup).getValue();
    
        }
        //read cost
        if (crmForm.all.new_cost != null) 
        {
            cost = Xrm.Page.getAttribute(new_cost).getValue();
        }
        //Calculate Resell
        var Resell = cost + ((markup*cost)/100);
        Xrm.Page.getAttribute(new_resellprice).setValue(Resell);
    }
    // if resell price change,it will calculate markup 
    function new_resellprice_onchange() 
    {
        //Script to Calculate Resell Price
        //Resell=Cost+((Markup*Cost))/100)
        var markup;
        var cost;
    
        //read cost
        if (crmForm.all.new_cost != null) 
        {
            cost = Xrm.Page.getAttribute(new_cost).getValue();
        }
        //read Resellprice
        if (crmForm.all.new_resellprice != null) 
        {
            Resell = Xrm.Page.getAttribute(new_resellprice).getValue();
        }
        //Calculate markup
        markup = ((Resell - cost) * 100) / cost;
        Xrm.Page.getAttribute(new_markup).setValue(markup);
    
    }
    
    
     
    
    
    
    
    
    
    
    



    sathishtech.IT

    Tuesday, September 25, 2012 10:10 AM

Answers

  • Hello,

    It seems that you forgot tu put quotes to following lines:

    markup = Xrm.Page.getAttribute(new_markup).getValue();

    ...

    cost = Xrm.Page.getAttribute(new_cost).getValue();

    ...

    Xrm.Page.getAttribute(new_resellprice).setValue(Resell);

    Should be

    markup = Xrm.Page.getAttribute('new_markup').getValue();

    ...

    cost = Xrm.Page.getAttribute('new_cost').getValue();

    ...

    Xrm.Page.getAttribute('new_resellprice').setValue(Resell);

    And the same for all fields.


    Freelance Developer for Dynamics CRM 4.0/2011

    • Proposed as answer by Andreas Buchinger Tuesday, September 25, 2012 11:05 AM
    • Marked as answer by sathishtech Tuesday, September 25, 2012 11:11 AM
    Tuesday, September 25, 2012 10:21 AM
    Moderator

All replies

  • where is the onload function?

    Haris Adil e-Bizsoft

    Tuesday, September 25, 2012 10:16 AM
  • Hello,

    It seems that you forgot tu put quotes to following lines:

    markup = Xrm.Page.getAttribute(new_markup).getValue();

    ...

    cost = Xrm.Page.getAttribute(new_cost).getValue();

    ...

    Xrm.Page.getAttribute(new_resellprice).setValue(Resell);

    Should be

    markup = Xrm.Page.getAttribute('new_markup').getValue();

    ...

    cost = Xrm.Page.getAttribute('new_cost').getValue();

    ...

    Xrm.Page.getAttribute('new_resellprice').setValue(Resell);

    And the same for all fields.


    Freelance Developer for Dynamics CRM 4.0/2011

    • Proposed as answer by Andreas Buchinger Tuesday, September 25, 2012 11:05 AM
    • Marked as answer by sathishtech Tuesday, September 25, 2012 11:11 AM
    Tuesday, September 25, 2012 10:21 AM
    Moderator
  • u r partially right but instead of single quotes 

    Xrm.Page.getAttribute('new_resellprice').setValue(Resell);

    double quotes should be used

    Xrm.Page.getAttribute("new_resellprice").setValue(Resell);



    sathishtech.IT


    • Edited by sathishtech Tuesday, September 25, 2012 11:02 AM
    Tuesday, September 25, 2012 11:01 AM
  • double quotes should be used

    Xrm.Page.getAttribute("new_resellprice").setValue(Resell);

    after putting double quotes to fields

    i am not getting the output


    sathishtech.IT

    Tuesday, September 25, 2012 11:07 AM
  • u r partially right but instead of single quotes 


    Just for your information:

    It doesn't matter what quotes should be used in JScript.

    'something' is equal to "something".

    So I believe that I helped you to solve your issue. Could you be sooooooo kind and mark my reply as answer.


    Freelance Developer for Dynamics CRM 4.0/2011

    Tuesday, September 25, 2012 11:09 AM
    Moderator