Can I use Global workflow function in any Sheet's Approval workflow?

In Global workflow:

function getDate(){
    return new Date();
}

In Sheet’s Approval workflow:

var Action = {
    Create: 'CREATE',
    Reject: 'REJECT',
    Finish: 'FINISH',
    Cancel: 'CANCEL',
}


try {
    // Get NodeID
    var nodeId = approvalParam.getEntryRootNodeId();
    // Get Approval Status
    var action = approvalParam.getApprovalAction();
  
    var now = getDate(); // wrong here
  
    switch (action) {
        case Action.Finish:
            log(nodeId, "do Finish");
            log(nodeId, now); 
            break;
        case Action.Cancel:
            log(nodeId, "do Cancel");
            log(nodeId, now);
            break;
    }


} catch (error) {
    log(nodeId, "error:" + error.message)
}
/** write debug message in record */
function log(nodeId, text) {

    var query = db.getAPIQuery("/ragicinventory/17"); 

    var record = query.getAPIEntry(nodeId); 

    record.setFieldValue(999,
        record.getFieldValue(999) +
        "\r\n" +
        text);
    record.save();

}

Then try to sign this sheet,in my debug message always show “getDate” is not defined

Is it because I set it wrong or is it a bug?

Thanks in advance,
Bonder

Hi,

The global workflow was not included in the approval workflow. It will be added available for use on our update tomorrow. You can try again after our update on Tuesday.

Thanks,
Jeff

Thanks for your reply,It’s working now.

I have another question,I setting timezone(GMT+8) in account settings.


When using “new Date()”,It always show GMT+0 time ?
Tue Nov 10 2020 04:16:12 GMT+0000 (UTC)

I can using global variable to fix this problem,but it not a good solution.

Thanks in advance,
Bonder

========
update

I use account.getTimeZoneOffsetInHours() to reslove my question.

Thanks,
Bonder