Tuesday, April 17, 2007

Setting a Default SLA in the out of the box.

Here is a bit of Code that will allow you to set the default value of a link field. This specific example sets the default value of the SLALink field on Incident based on the priority.


import System
import Fusion
import Fusion.Api

class FusionScriptWrapper implements IScriptWrapper
{
function FusionScriptWrapper()
{
// place constructor logic here
}

function Process(currentBusinessObject : Fusion.Api.BusinessObject, currentField : Fusion.Api.Field) : Object
{
var objReturn : Object;
var defaultSLARecId: String;
var highPrioritySLARecId: String;

// first set the link to null
currentBusinessObject.GetField("DefaultEscalationLink+LinkID").SetValue(new Fusion.FusionValue(""));
currentBusinessObject.GetField("DefaultEscalationLink+LinkCategory").SetValue(new Fusion.FusionValue(""));

// Set the value of the RecID of the Default SLA
defaultSLARecId = "00000000000000000000000000000000";
// Set the value of the RecID of the High Priority SLA
highPrioritySLARecId = "00000000000000000000000000000000";

// then set the link to either the default or high priority sla
if(currentBusinessObject.GetField("Priority").NativeValue == "1")
{
currentBusinessObject.GetField("DefaultEscalationLink+LinkID").SetValue(new Fusion.FusionValue(highPrioritySLARecId));
currentBusinessObject.GetField("DefaultEscalationLink+LinkCategory").SetValue(new Fusion.FusionValue("SLA"));
}
else
{
currentBusinessObject.GetField("DefaultEscalationLink+LinkID").SetValue(new Fusion.FusionValue(defaultSLARecId));
currentBusinessObject.GetField("DefaultEscalationLink+LinkCategory").SetValue(new Fusion.FusionValue("SLA"));
}


return objReturn;

}
}

No comments: