HPSM Issue: i am locking direct change from intraction.

function getNumberField(fileName)
{

var nextNumber = new SCDatum ;
var callRtn =new SCDatum;
system.functions.rtecall("getnumber", callRtn, nextNumber, fileName);
return nextNumber;
}

function getNextSequentialNumber()
{
var numberFile = new SCFile("number");
var rc = numberFile.doSelect("name=\"" "cm3r" "\"");
if (rc==RC_SUCCESS)
{
numberFile.number ;
numberFile.doUpdate();
var theNextNumber = numberFile.number;
var theNextNumberString = theNextNumber.toString();
theNextNumberString = numberFile.prefix theNextNumberString;
//print("numberString =" theNextNumberString);
return theNextNumberString;
}
}

function checkRole()
{
var role = system.vars.$lo_user_role;
return role;
}


var userrole = checkRole();
var user = system.vars.$lo_user_name;
var assignment = system.vars.$lo_pm_assignments;
var assign_grp1 = system.vars.$file.assignment_grp;

//if (userrole != "CRO" && userrole != "General User"){
//if (userrole != "General User"){
if (assign_grp1=="NOSS" || assign_grp1=="CC HelpDesk - Huawei FLM Team")
{
var changeFile = new SCFile( "cm3r" );
var newCm3r = new SCFile( "cm3r" );
var NewRecord=system.vars.$file;

if (NewRecord.ess_entry==true) //&& assignment == "CC Development")
{
//newProbsummary.number =getNextSequentialNumber();
newCm3r.number=getNumberField("cm3r");
newCm3r.brief_description="test";
newCm3r.initial_impact="1 - Enterprise";
newCm3r.priority_code="LOW";
newCm3r.risk_assessment="1 - Low Risk";
newCm3r.planned_start=NewRecord.planned_start;
newCm3r.planned_end=NewRecord.planned_end;
newCm3r.tpaccountable="zakir khan";
newCm3r.tpaccountablephone="03458989898";
newCm3r.activitysupervisor="zakir ";
newCm3r.activitysupervisortelephone="03458989898";
newCm3r.location_full_name="Islamabad";
newCm3r.Change_Reason=NewRecord.Change_Reason;
newCm3r.system_impact=NewRecord.system_impact;
newCm3r.expected_benefits=NewRecord.expected_benefits;
newCm3r.region="zakir.khan";
newCm3r.subcategory="Planned Outages";
newCm3r.coordinator="zakir.khan";
newCm3r.CompName="TP";
newCm3r.down_start=NewRecord.down_start;
newCm3r.down_end=NewRecord.down_end;


// Current Incident ID
var ChangeID = newCm3r.number;
//print("incident creation success");
//print("Incident number",newProbsummary.number);
var rteReturnValue = new SCDatum();
var rteNames = new SCDatum();
var rteValues = new SCDatum();
rteNames.push("file");
rteNames.push("number1");
rteNames.push("numbers");
rteValues.push(newCm3r);
rteValues.push(newCm3r.contract_id);
var slaID="175";
newCm3r.agreement_ids=[slaID];
rteValues.push(newCm3r.agreement_ids);
//system.functions.rtecall("callrad",rteReturnValue,"sc.get.sla",rteNames,rteValues,false);
}
var rc = newCm3r.doInsert();
if (rc == RC_SUCCESS)
{
//print("Incident inserted successfully");
}
// var rc = newProbsummary.doAction("save");
//if (rc == RC_SUCCESS)
//{print("Insertion to Probsummary completed");
//var rc = newProbsummary.doAction("save");
//var rc = newProbsummary.doUpdate();
//if (rc == RC_SUCCESS)
//{print("Action UPDATE been performed");


var newScRelation1 = new SCFile("screlation");
newScRelation1.depend_active=true;
var NewRecord3=system.vars.$file;
// print( "New Record is : ", NewRecord3);
newScRelation1.depend_filename="change";
//print("New SCRelation1.depend_filename is ", newScRelation1.depend_filename);
newScRelation1.depend=NewRecord3.change_id;
//print("New SCRelation1.depend is ", newScRelation1.depend);
newScRelation1.source_active=true;
//print("New SCRelation1.depend_filename is ", newScRelation1.source_active);
newScRelation1.source_filename="Change";
//print("New SCRelation1.depend_filename is ", newScRelation1.source_filename);
newScRelation1.source=newCm3r.number;
//print("New SCRelation1.depend_filename is ", newScRelation1.source);
//print("Open time is:", NewRecord3.open_time);
//print("Open by is:", user);
newScRelation1.desc= new Array(user,NewRecord3.open_time,NewRecord3.open);
//print("New SCRelation1.depend_filename is ", newScRelation1.desc);
var rel1 = newScRelation1.doInsert();
//if (rel1 == RC_SUCCESS) -- commented by kashif
//print("SC Relation Record Entered as well");
}

//Set the screlation between interaction and incidents

/*function addincidentRelations(NewRecord,newProbsummary)
{

var newScRelation1 = new SCFile("screlation");
newScRelation1.depend_active=true;
newScRelation1.depend_filename="incidents";
newScRelation1.depend=NewRecord.incident_id;
print("Checking the print",newScRelation1.depend);
newScRelation1.source_active=true;
newScRelation1.source_filename="problem";
newScRelation1.source=newProbsummary.number;
//newScRelation1.desc= new Array(newProbsummary.open_time,newProbsummary.opened_by,newProbsummary.open);
//var rel1 = newScRelation1.doInsert();
if (rel1 == RC_SUCCESS)
print("First thing done success ALHAMDULILAH!");

var newScRelation2 = new SCFile("screlation");
newScRelation2.depend_active=true;
newScRelation2.depend_filename="problem";
newScRelation2.depend=incidentRecord.number;
newScRelation2.source_active=true;
newScRelation2.source_filename="incidents";
newScRelation2.source=interactionRecord.incident_id;
newScRelation2.desc= new Array(incidentRecord.open_time,incidentRecord.problem_status,incidentRecord.category,incidentRecord.action);
var rel2 = newScRelation2.doInsert();
if (rel2 == RC_SUCCESS)
print("rel2 success");
} */