[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1153
  • Last Modified:

CRM 2011 - Calculating Commisions

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
apollo7
Asked:
apollo7
  • 7
  • 6
1 Solution
 
Chinmay PatelEnterprise ArchitectCommented:
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
 
apollo7Author Commented:
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
 
Chinmay PatelEnterprise ArchitectCommented:
Hmmmm What exactly happens with the second script? you get an error?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
apollo7Author Commented:
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
 
Chinmay PatelEnterprise ArchitectCommented:
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
 
apollo7Author Commented:
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
 
Chinmay PatelEnterprise ArchitectCommented:
Did you try :

Xrm.Page.getAttribute("commissiontotal").setValue(TotalComm);
0
 
apollo7Author Commented:
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
 
Chinmay PatelEnterprise ArchitectCommented:
Hmmmm Can I look at the script? I mean in action? TeamViewer?
0
 
apollo7Author Commented:
Chinmay,

I kept changing it and got it to work!  

Thanks very much for your help :)
0
 
Chinmay PatelEnterprise ArchitectCommented:
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
 
apollo7Author Commented:
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
 
apollo7Author Commented:
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 7
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now