When we are trying to close the service Request unless and until all the activities under that service request has status “Close”*/
when we are trying to close the service Request unless and until all the activities under that service request has status “Done”*/
Ans: Multiple ways we can do
1. Through Script
2. Through DVM
3. Through WF
1.
function BusComp_PreSetFieldValue (FieldName, FieldValue)
{
if(FieldName == "Status")
{
if(FieldValue == "Closed")
{
var bosrvreq = TheApplication().ActiveBusObject();
var bcsrvreq = bosrvreq.GetBusComp("Service Request");
var bcaction = bosrvreq.GetBusComp("Action");
var srid = this.GetFieldValue("Id");
with(bcaction)
{
ActivateField("Status");
ActivateField("Activity SR Id");
SetViewMode(3);
ClearToQuery();
SetSearchSpec("Activity SR Id", srid);
ExecuteQuery();
}
var firstrec = bcaction.FirstRecord();
while(firstrec != 0)
{
if(bcaction.GetFieldValue("Status") == "Close")
{
firstrec = bcaction.NextRecord();
}
else
{
TheApplication().RaiseErrorText("You cannot close this SR untill all the activities are Close");
return(CancelOperation);
}
}
}
}
return (ContinueOperation);
}
Comments
Post a Comment