Difference between revisions of "Pandora - Sample - Updating Level 2 Items"
From SmartWiki
Michael Reid (talk | contribs) |
Michael Reid (talk | contribs) |
||
Line 1: | Line 1: | ||
− | = Sample Code - Updating a UTA Level 2 item from a Company Transaction = | + | = Sample Code - Updating a UTA Level 2 item from a Company and/or Personal Transaction = |
− | The following code sample will be of interest to developers wishing to update a UTA Level 2 item with values stored in company or personal transaction. | + | The following code sample will be of interest to developers wishing to update a UTA Level 2 item with values stored in company and/or personal transaction. |
The particular use for this code is in the Medical Assessment Market where you wish to update a service (Level 2 item) with the billing amount for that service. | The particular use for this code is in the Medical Assessment Market where you wish to update a service (Level 2 item) with the billing amount for that service. | ||
+ | |||
+ | == Payer Behaviour == | ||
* The billing amount is derived from a company transaction associated with the payer company. | * The billing amount is derived from a company transaction associated with the payer company. | ||
* The payer company is associated with the Case (level 1). | * The payer company is associated with the Case (level 1). | ||
+ | * The level 2 service name is matched to the Transaction name. | ||
+ | * If no matching transaction can be located in the payer company then a generic payer company is used to get the billing amount. | ||
+ | |||
+ | == Provider Behaviour == | ||
+ | |||
+ | * A cost amount for the service is derived from the provider for the service. | ||
+ | * The provider must have been assiocated with the service (single provider only in this code) | ||
+ | * The level 2 service name is matched to the Transaction name. | ||
+ | * If no matching transaction can be located in the provider then a generic provider is used to get the cost amount. | ||
+ | |||
+ | * The code should be located in a Script field on the Level 2 entity. | ||
* The code is associated with the Save function on the level 2 page. | * The code is associated with the Save function on the level 2 page. | ||
<PRE> | <PRE> | ||
− | |||
function savefunc(frm) { | function savefunc(frm) { |
Latest revision as of 17:41, 20 July 2010
Sample Code - Updating a UTA Level 2 item from a Company and/or Personal Transaction
The following code sample will be of interest to developers wishing to update a UTA Level 2 item with values stored in company and/or personal transaction.
The particular use for this code is in the Medical Assessment Market where you wish to update a service (Level 2 item) with the billing amount for that service.
Payer Behaviour
- The billing amount is derived from a company transaction associated with the payer company.
- The payer company is associated with the Case (level 1).
- The level 2 service name is matched to the Transaction name.
- If no matching transaction can be located in the payer company then a generic payer company is used to get the billing amount.
Provider Behaviour
- A cost amount for the service is derived from the provider for the service.
- The provider must have been assiocated with the service (single provider only in this code)
- The level 2 service name is matched to the Transaction name.
- If no matching transaction can be located in the provider then a generic provider is used to get the cost amount.
- The code should be located in a Script field on the Level 2 entity.
- The code is associated with the Save function on the level 2 page.
function savefunc(frm) { fillFee(frm); return true; } function fillFee(frm){ /* Following variables must be set for each instance */ ss_developer_key="237753-xU7Kd1o2FAH/cuHfLZcTO8SdXzE3g7wmiWFPdoez/9Q="; var COMPANYTRANSACTIONTYPEID=64;//company transaction type id var GENERICTRANSACTIONCOMPANYID=479981;//company id being used for generic company transactions var PAYERFEECUSTOMFIELDID=569340;//level2 payer fee custom field id for company transaction fee found var PEOPLETRANSACTIONTYPEID=65;//people transaction type id var GENERICTRANSACTIONUSERID=0;//user id being used for generic people transactions var ASSESSORFEECUSTOMFIELDID=569377;//level 2 assessor custom field id for people transaction fee found //------------------------------END--------------------- var companyid="@parent.client.companyid@";//get level 1 client companyid var servicename=frm.eventtype.options[frm.eventtype.selectedIndex].text;//get level 2 service name and split into an array since it is a multiple level combo box custom field var criteria="trstranstype="+COMPANYTRANSACTIONTYPEID+" and trsobjectid in('"+companyid+"',"+GENERICTRANSACTIONCOMPANYID+") and $Assessment$='"+servicename+"'";//search for level 1 client company transaction var rs=trans_find(false ,"","$Schedule fee$,$Assessment$",criteria,"","","",0,1); var valuestr="0"; if(rs!=null&&rs.recordcount>0)valuestr=rs.getfieldbyname(1,"$Schedule fee$"); document.getElementById("cf_"+PAYERFEECUSTOMFIELDID).value=valuestr;//fill level 2 custom field "Payer Fee" with transaction schedule fee found var userid=frm.contact.value.replace(/^,|,$/,"");//find level 2 contact userid if (userid=="")return;//if there is no contact associated with level 2, do nothing criteria="trstranstype="+PEOPLETRANSACTIONTYPEID+" and trsobjectid in('"+userid+"',"+GENERICTRANSACTIONUSERID+")";//search for level 2 contact user transaction criteria+="and $Service Name$='"+servicename+"'";//transaction service type match level 2 service name rs=trans_find(false ,"","$Service Name$,$Fee$",criteria,"","","",0,1);//find trasaction fee according to above criteria valuestr="0"; if(rs!=null&&rs.recordcount>0)valuestr=rs.getfieldbyname(1,"$Fee$"); document.getElementById("cf_"+ASSESSORFEECUSTOMFIELDID).value=valuestr;//fill transaction fee to level 2 custom field "Assessor Flat Fee" } </script> <SCRIPT type="text/javascript" language=JavaScript src="/Ajax/uta/uta.js">