ALARMus Acclaimed Contributor.
Acclaimed Contributor.
325 views

Set custom record to function call

Jump to solution

There is ability in triggers to call function (function in scriptlibrary) and set record as argument for this function

lib.mylib.myfunc (arg1, arg2, record)

Is it possible to set another "record", more exactly to set "record" of another table into function argument ?

0 Likes
1 Solution

Accepted Solutions
ALARMus Acclaimed Contributor.
Acclaimed Contributor.

Re: Set custom record to function call

Jump to solution

I did it using standart JS command

Notification to approvers contains data only from current table (Approval) if use standart triggers for table approval.

I need insert more info about user into this email for approvers.

So for triggers (for approval table)

Before: 

Spoiler

 

if (record.name=="Standart request" && record.approval_status != "denied" && ((record.name!=oldrecord.name)||(system.functions.str(record.future_groups)!=system.functions.str(oldrecord.future_groups))))
{
	var approvers = new Array();
	approvers = record.current_pending_groups;
	for (i in approvers){
	print("Триггер ig.approval.notif, текущий согласующий:"+approvers[i]);
		lib.HPCNotify.SendEmailToOperator(approvers[i], "Request-Approval", "Request-Approval" , record)	
	}
}
 

So i can use variable from Approval table to insert its value to email.

After:

Spoiler

 

if (record.name=="Standart request" && record.approval_status != "denied" && ((record.name!=oldrecord.name)||(system.functions.str(record.future_groups)!=system.functions.str(oldrecord.future_groups))))
{
	var approvers = new Array();
	approvers = record.current_pending_groups;
			
	for (i in approvers)
	{
	var ocmqFile = new SCFile("ocmq")
	var ocmqrec = ocmqFile.doSelect("number=\""+record.unique_key+"\"")
		if (ocmqrec == RC_SUCCESS)
		{
			lib.HPCNotify.SendEmailToOperator(approvers[i], "Request-Approval", "Request-Approval" , ocmqFile)
		}
	}
}
 

Now i can use value of variable from OCMQ table to insert it in email.

 

View solution in original post

0 Likes
2 Replies
Alexander Emelyanov Super Contributor.
Super Contributor.

Re: Set custom record to function call

Jump to solution

Hello, yes, of course, try smthing like this:

 

var $ = lib.c.$;

//trying to get record

var yourTableName = 'example';

var sql = 'id=101010';

var arg_record = $(yourTableName).select(sql).uniqueResult();

lib.yourLib.yourFunc(arg1, arg2, arg_record);

 

If the sql query does not have records in your table, the function will return null.

 

ALARMus Acclaimed Contributor.
Acclaimed Contributor.

Re: Set custom record to function call

Jump to solution

I did it using standart JS command

Notification to approvers contains data only from current table (Approval) if use standart triggers for table approval.

I need insert more info about user into this email for approvers.

So for triggers (for approval table)

Before: 

Spoiler

 

if (record.name=="Standart request" && record.approval_status != "denied" && ((record.name!=oldrecord.name)||(system.functions.str(record.future_groups)!=system.functions.str(oldrecord.future_groups))))
{
	var approvers = new Array();
	approvers = record.current_pending_groups;
	for (i in approvers){
	print("Триггер ig.approval.notif, текущий согласующий:"+approvers[i]);
		lib.HPCNotify.SendEmailToOperator(approvers[i], "Request-Approval", "Request-Approval" , record)	
	}
}
 

So i can use variable from Approval table to insert its value to email.

After:

Spoiler

 

if (record.name=="Standart request" && record.approval_status != "denied" && ((record.name!=oldrecord.name)||(system.functions.str(record.future_groups)!=system.functions.str(oldrecord.future_groups))))
{
	var approvers = new Array();
	approvers = record.current_pending_groups;
			
	for (i in approvers)
	{
	var ocmqFile = new SCFile("ocmq")
	var ocmqrec = ocmqFile.doSelect("number=\""+record.unique_key+"\"")
		if (ocmqrec == RC_SUCCESS)
		{
			lib.HPCNotify.SendEmailToOperator(approvers[i], "Request-Approval", "Request-Approval" , ocmqFile)
		}
	}
}
 

Now i can use value of variable from OCMQ table to insert it in email.

 

View solution in original post

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.