Hi there,
I am writing a Javascript using XrmToolBox. It is a QuoteLine entity which every user/seller need to fill in the products, etc.
I'm trying to get the current user's business unit because every business unit has their own taxcode and I need to make specific calculations based on this.
So this is my current code:
function QuoteLineOnChange()
{
var taxcode = Xrm.Page.getAttribute("srkk_taxcode_");
var businessunit = Xrm.Page.getAttribute("owningbusinessunit").getValue()[0].name;
if (businessunit == "A1")
{
if (taxcode.getText() == "SST1")
{
Xrm.Page.getAttribute("srkk_tax").setValue(6);
Xrm.Page.getAttribute("priceperunit").fireOnChange();
}
else
{
Xrm.Page.getAttribute("srkk_tax").setValue(0);
Xrm.Page.getAttribute("priceperunit").fireOnChange();
}
}
else if (businessunit == "A2")
{
if (taxcodesg.getText() == "SR")
{
Xrm.Page.getAttribute("srkk_tax").setValue(7);
Xrm.Page.getAttribute("priceperunit").fireOnChange();
}
else
{
Xrm.Page.getAttribute("srkk_tax").setValue(7);
Xrm.Page.getAttribute("priceperunit").fireOnChange();
}
}
else
{
Xrm.Page.getAttribute("srkk_gstsst").setValue(0);
}
}
So as you can see, Business Unit A1 and A2 has their own value. But the seem cannot get the business unit that I refer to. Is there a problem on the RED code that I wrote? I need some help