Solved

CRM 2011 - Calculating Commisions

Posted on 2011-09-21
13
1,145 Views
Last Modified: 2012-05-12
Hi

Is there a built in way to create salesperson commissions in CRM 2011?  I have looked through the software but do not see one.

If not, can it be done using javascript or a workflow?

Thanks
0
Comment
Question by:apollo7
  • 7
  • 6
13 Comments
 
LVL 27

Expert Comment

by:Chinmay Patel
ID: 36573851
Hi apollo7,

There is no built in way to do so. However you can do it by JavaScript or Workflow but will have to see exact requirement for the same.

Regards,
Chinmay.
0
 
LVL 1

Author Comment

by:apollo7
ID: 36575985
I am trying to get used to the formatting of script in CRM 2011.  I have defined a function and populated it with script.  The first script works (var controlsLength) and the second one (var commrate) does not.

Any suggestions?

Thanks
function getControlCount() 
{

 var controlsLength = Xrm.Page.ui.controls.getLength();
 alert("This form has " + controlsLength + " controls on it.");

 var commrate = Xrm.Page.ui.controls.get("name");
 alert("This form has " + commrate + " on it.");
 
}

Open in new window

0
 
LVL 27

Expert Comment

by:Chinmay Patel
ID: 36578288
Hmmmm What exactly happens with the second script? you get an error?
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 1

Author Comment

by:apollo7
ID: 36579537
Chinmay,
Thanks for the response.  I have gotten past the second script issue and now have a different issue.  What I am trying to do, btw, is to take a commission rate (from an invoice form), mulitiply it by the totalamount field and come up with a total commission amount (also on the invoice form).

The code below works except for the final calculation.  No error, it justs not return anything when from the alert - alert(TotalComm);

I appreciate your help.

function AlertRateField() {
    var MainRate = Xrm.Page.data.entity.attributes.get("new_commissionrate").getValue();
    alert(MainRate);

    var MainComm = Xrm.Page.data.entity.attributes.get("new_commissiontotal").getValue();
    alert(MainComm);

    var MainTotal = Xrm.Page.data.entity.attributes.get("totalamount").getValue();
    alert(MainTotal);

    var TotalComm = MainTotal * MainRate;
    alert(TotalComm);

}

Open in new window

0
 
LVL 27

Expert Comment

by:Chinmay Patel
ID: 36579573
Hi apollo7,

Do you get a message box? or you dont get the message box?
also try

var TotalComm = parseInt(MainTotal) * parseInt(MainRate);

Open in new window



instead of

var TotalComm = MainTotal * MainRate;

Open in new window



Regards,
Chinmay.
0
 
LVL 1

Author Comment

by:apollo7
ID: 36580046
Ok, I have all the get statements working and all the alerts return the correct values.

Now I am trying to set the value of new_commissiontotal (var MainComm) to the value of the  TotalComm.variable.  

Any suggestions on this?  I have tried serveral set options and keep getting the "value is null" errors.

The code that works is below.

Thanks
function AlertRateField() {
    
    var MainRate = Xrm.Page.data.entity.attributes.get("new_commissionrate").getValue();
    alert(MainRate);

    var MainComm = Xrm.Page.data.entity.attributes.get("new_commissiontotal").getValue();
    alert(MainComm);

    var MainTotal = Xrm.Page.data.entity.attributes.get("totalamount").getValue();
    alert(MainTotal);

    var TotalComm = MainTotal * MainRate;
    alert(TotalComm);
    
}

Open in new window

0
 
LVL 27

Accepted Solution

by:
Chinmay Patel earned 500 total points
ID: 36580074
Did you try :

Xrm.Page.getAttribute("commissiontotal").setValue(TotalComm);
0
 
LVL 1

Author Comment

by:apollo7
ID: 36580557
Chinmay

Tried the code you have above and also the following.  In both cases, I get the error:
Object doesn't support property or method "getAttribute"


function AlertRateField() {
    
    var MainRate = Xrm.Page.data.entity.attributes.get("new_commissionrate").getValue();
    alert(MainRate);

    var MainComm = Xrm.Page.data.entity.attributes.get("new_commissiontotal").getValue();
    alert(MainComm);

    var MainTotal = Xrm.Page.data.entity.attributes.get("totalamount").getValue();
    alert(MainTotal);

    var TotalComm = MainTotal * MainRate;
    alert(TotalComm);
    
     Xrm.Page.data.entity.attributes.getAttribute("new_commissiontotal").setValue(TotalComm); 
}

Open in new window

error1.jpg
0
 
LVL 27

Expert Comment

by:Chinmay Patel
ID: 36581110
Hmmmm Can I look at the script? I mean in action? TeamViewer?
0
 
LVL 1

Author Comment

by:apollo7
ID: 36581866
Chinmay,

I kept changing it and got it to work!  

Thanks very much for your help :)
0
 
LVL 27

Expert Comment

by:Chinmay Patel
ID: 36583139
Hi apollo7,

Do post the correct script and as usual if it was you who figured it out... points should go to your post.

Regards,
Chinmay.
0
 
LVL 1

Author Comment

by:apollo7
ID: 36583649
Chinmay,

I will post the script that works - it is a variation on one of  your posts, however, I understand what you are saying.  I do think you should get the points but lets decide after I post the script.

Thanks
0
 
LVL 1

Author Comment

by:apollo7
ID: 36583723
Chinmay,

This is the script that worked for me:
   Xrm.Page.getAttribute("new_commissiontotal").setValue(TotalComm);

If you compare it to the script that you posted and I awarded the points to:
   Xrm.Page.getAttribute("commissiontotal").setValue(TotalComm);

you will see they are very close.  Also, when I said "I kept changing it and got it to work!", what I should have said was that I made a lot of changes that didnt help things and then I saw that I just needed to add "new_" to "commissiontotal".  After I made that change, it worked fine.

Thanks again for your help.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question