Set custom record to function call

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 ?

  • 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.

     

  • Verified Answer

    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: 

     

    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:

     

    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.