function WebApplet_PreInvokeMethod (MethodName)
{
if(MethodName == "WriteRecord")
{
var Bo = this.BusObject();
var Bc = Bo.GetBusComp("Employee");
var sType =Bc.GetFieldValue("Employee Type Code");
var RecId =Bc.GetFieldValue("Id");
if(sType != "Recruit-Offsite" && sType != "Recruit-Onsite" && sType != "Recruit-Subcontractor" )
{
var CurrentLogin = TheApplication().LoginName();
var EmpBo = TheApplication().GetBusObject("Employee");
var EmpBc = EmpBo.GetBusComp("Employee");
var PosBc;//for getting position Bc
var b=0;
var isRecord;
var a=0;
var z="";
var pos= new Array();
with (EmpBc)
{
SetViewMode(3);
ClearToQuery();
SetSearchSpec("Login Name",CurrentLogin);
ExecuteQuery();
if (FirstRecord())
{
PosBc = GetMVGBusComp("Position");// this method invokes the position MVG for the employee
}
}
with (PosBc)
{
ActivateField("Name");
ClearToQuery();
ExecuteQuery();
b=CountRecords();
var count1= new Array(b);
if (FirstRecord())
{
for (var i=0;i
{
count1[i] = GetFieldValue("Name");
//The list of all positions will be stored in count1[] array.
NextRecord();
}
}
}
for (z=0;z
{
pos = count1[z]
if(pos == "VP Human Resources" || pos == "Human Resource Manager")
{
var ActBo = this.BusObject();
var ActBc = ActBo.GetBusComp("Action");
ActBc.SetViewMode(3);
ActBc.ClearToQuery();
ActBc.SetSearchSpec("Contact Id",RecId);
ActBc.ExecuteQuery(ForwardOnly);
var co = ActBc.CountRecords();
isRecord = ActBc.FirstRecord();
while (isRecord)
//validating the activities for closed state
{
var ActStatus = ActBc.GetFieldValue("Status");
//var str = "I don't like soggy cereal."
var substr = Clib.strrchr(ActStatus, 'D');
if (substr != "Done")
{ TheApplication().RaiseErrorText("One or more 'Activities' of the recruit is not 'Done'"); }
isRecord = ActBc.NextRecord()
}
pos = null;
return (ContinueOperation);
}
z++;
}
TheApplication().RaiseErrorText("You do not have the permission to change the 'Recruit Type'");
return (CancelOperation);
}
return (ContinueOperation);
}
}



