<platform_solution><objects><form_script><parameters></parameters><name>setProjectRiskInformation.js</name><association>project_edit_form</association><event>after_save</event><libraries></libraries><comments></comments><code><![CDATA[/**
* Copyright NetSuite, Inc. 2014 All rights reserved.
* The following code is a demo prototype. Due to time constraints of a demo,
* the code may contain bugs, may not accurately reflect user requirements
* and may not be the best approach. Actual implementation should not reuse
* this code without due verification.
*
* Set the risk profile of a project using a custom field.
*
* Version Date Author Remarks
* 1.00 24 Jul 2014 Ryan Morrissey
*
*/
function setProjectRiskInformation(type) {
try {
var FLD_RISK = 'prj_overall_risk__c',
FLD_RISK_ID = 'prj_overall_risk_value__c',
FLD_RISK_COLOR = 'prj_overall_risk_color__c';
var recProj = NSOA.form.getNewRecord();
if (!recProj || !recProj[FLD_RISK]) {
return;
}
var risk_colors = {
/*
* For information on colors and palattes, visit
* the confluence page for Team OpenAir
* https://confluence.corp.netsuite.com/display/TeamOA/UI+Graphic+Rules
*/
'5': '#bf340f', // dark red
'4': '#f89406', // orange
'3': '#ffee5a', // yellow
'2': '#0099cc', // dark blue
'1': '#afc437' // green
};
var risk_array = recProj[FLD_RISK].split('-'),
risk_id = risk_array[0],
risk_str = risk_array[1];
var color_tag = '<div style="height:15px;width:15px;display:block;margin:0 auto;' +
'border-radius:15px;-moz-border-radius:15px;-webkit-border-radius:15px;' +
'background-color:' + risk_colors[risk_id] + ';border:1px solid ' + risk_colors[risk_id] +
';"></div>';
var objProj = new NSOA.record.oaProject();
objProj.id = recProj.id;
objProj[FLD_RISK_ID] = risk_id;
objProj[FLD_RISK_COLOR] = color_tag;
NSOA.wsapi.disableFilterSet(true);
var results = NSOA.wsapi.modify([{name: 'update_custom', value: '1'}], [objProj]);
} catch(e) {
NSOA.meta.log('error', 'Try/catch error: ' + e);
}
}]]></code><entrance_function>setProjectRiskInformation</entrance_function></form_script></objects><version>1.0</version><title>NetSuite: Project Risk Indicator</title><description></description></platform_solution>