Resources for IT Professionals > Dynamics Forums > CRM > Can 2 fields compute into a third field
Ask a questionAsk a question
 

AnswerCan 2 fields compute into a third field

  • Friday, November 06, 2009 4:33 PMShannonBarrett Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I need to see if I can get a product total field and a maintenance total field to add together and put the total into a total field.  Has anyone done this before?

Answers

  • Friday, November 06, 2009 4:53 PMMayankP Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas Code

    You can do this using Java script as follows...put this onSave of Form

    var iristotal = 0;
    
    if(crmForm.all.<<product total field>>.DataValue != null  &&  crmForm.all.<<maintenance total field>>.DataValue != null )
    { 
      iristotal = crmForm.all.<<product total field>>.DataValue + crmForm.all.<<maintenance total field>>.DataValue;
    
    crmForm.all.<<total field>>.DataValue = iristotal;
    
    }		<br/><br/><br/>
    

    Please have a look at this article for more details on this.

All Replies

  • Friday, November 06, 2009 4:44 PMAhmed ElNoby Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi Shannon,

    There is the onChange Event for each field in the CRM Form fields using this you can use javascript code to calculate and put the total in the third field

    and you can access the fileds by crmForm.all.<FieldName>

    i.e. crmForm.all.<Field3>.value = crmForm.all.<Field1>.value + crmForm.all.<Field2>.value;

    Hope this helps.

    Thanks,
  • Friday, November 06, 2009 4:53 PMMayankP Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas Code

    You can do this using Java script as follows...put this onSave of Form

    var iristotal = 0;
    
    if(crmForm.all.<<product total field>>.DataValue != null  &&  crmForm.all.<<maintenance total field>>.DataValue != null )
    { 
      iristotal = crmForm.all.<<product total field>>.DataValue + crmForm.all.<<maintenance total field>>.DataValue;
    
    crmForm.all.<<total field>>.DataValue = iristotal;
    
    }		<br/><br/><br/>
    

    Please have a look at this article for more details on this.

  • Friday, November 06, 2009 4:58 PMShannonBarrett Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Thank you both very muc for your answers, I will be working on this today!  Have a great day/weekend.

     

    Shannon

  • Friday, November 06, 2009 6:44 PMDonna EdwardsMVP, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    If you need some additional information, you can have a look at this article
    Best Regards, Donna