New Ranks & Badges For The Community!
Notice something different? The ranks and associated badges have gone "Star Fleet". See what they all mean HERE
Highlighted
Absent Member.
Absent Member.
519 views

JavaScript crashing system on doSave

I am trying to write a Javascript function to save a new record from RAD line. Pretty simple. But whenever it Runs and I do a SCFile.doSave() it crashes with a SOAP error. if I do SCFile.doAction("Add") the RC result is "Unspecified Error". I attached a screenshot of what happens when it crashes. Can anyone help me resolve why it is crashing:

 

function createAssignment( pGroup){

var fTmpAssignment =newSCFile("assignment");

fTmpAssignment.name = pGroup;

//With or without this following line it crashes

fTmpAssignment.oti_name =pGroup;

print(fTmpAssignment);

var rc = fTmpAssignment.doSave();

if( rc == RC_SUCCESS ){

print("Succesfully added Assignment Group and Members "+ pGroup +".");

}

else{

print("Error: Unsuccesfully added Assignment Group and Members "+ pGroup +".");

}

return true;

}

0 Likes
6 Replies
Highlighted
Absent Member.
Absent Member.

function createAssignment(pGroup)

{

   var group = new SCFile("assignment");
   var rc = group.doSelect("name=\""+pGroup+"\"");

 

   if (rc == RC_SUCCESS)
      print("Assignment Group already exists");
   else
   {
      group.name = pGroup;
      group.doInsert();
   }

}

 

Note: Consider checking that pGroup is populated within the function

0 Likes
Highlighted
Absent Member.
Absent Member.

doInsert() has produced a different issue than before. This time it said there was a different issue with it:

Insert cancelled by trigger (display,fdisp.1)
file:(assignment) key:(name=newgroupnamehere) (display,fdisp.1)
Error: Unsuccesfully added Assignment Group and Members turtle.
Return Code: Trigger Error

0 Likes
Highlighted
Absent Member.
Absent Member.

basically what I'm trying to do is move assignment groups from one environment to the next. The problem is moving the assignment groups doesnt call the triggers and the operator needs to be updated with the correct assignment groups.

 

If you don't manually enter them we get an issue with the assignment group not being on the operator record. This was something I was trying to solve through javascript. If any other suggestions are out there, that would be helpful.

0 Likes
Highlighted
Absent Member.
Absent Member.

I confirmed the sample solution works in SM 7.11 and 9.21. Is it possible that someone has modified the triggers against the assignment file?

 

Note: The OOB system has triggers against the assignment file to update operator records (RAD: trigger.assignment.oper.add). Therefore, it should work to simply unload records from one system and load them into another (assuming the same set of operators are used).

0 Likes
Highlighted
Absent Member.
Absent Member.

I really have no idea. Not that I havn't looked and don't care to but my team has literally touched every corner of this system it wouldn't surpise me. It just looks like another case of something in our system doesnt perform the same as another.  It looks like I am just going to have to manually enter all the groups again!

0 Likes
Highlighted
Absent Member.
Absent Member.

It doesn't make sense that a manually populated assignment record can be added, but the equivalent in JavaScript encounters an error...

 

Another potential option is to export (as plain text) the assignment records and then import into the other system. If you make the operators array the last field in the export, you can use -1 for the Array Length in the Import Descriptor record to import a variable number of elements.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.