This topic contains 4 replies, has 0 voices, and was last updated by karenn 7 years ago.

  • Author
    Posts
  • #17856

    karenn

    Hello All,

    In 1.o we have used nlapiGetContext().getExecutionContext() to determine if a script is being triggered from web services or user interface. Well, I am not seeing the ability to do this in 2.0. I dumped scriptContext and nothing there. Looking at runtime but nothing seems to give me this info. Surely this is possible in 2.0 and I am just missing it.

    Thanks,

    Karen
    This is a cached copy. Click here to see the original post.

  • #17857

    Vesku1980

    Hi,

    Can you do it like this?

    This works in Suitelet/UE Script/Client script and Scheduled scripts.

    var scriptObj = runtime.getCurrentScript();

    log.audit({title: ‘Audit Entry’, details:”Remaining governance units END:: ” + scriptObj.getRemainingUsage()});

  • #17858

    karenn

    I have been able to get remaining usage for other things in the past but this time I need to know if it is being run in the context of Web Services or User Interface

  • #17859

    pcutler

    Have you tried runtime.executionContext in the N/runtime module?

    For example:

    Code:
    //Add additional code

    if (runtime.executionContext === runtime.ContextType.USEREVENT)
    return;

    //Add additional code

  • #17860

    karenn

    Appears this will do what I need. Thanks

You must be logged in to reply to this topic.