Friday, June 17

Getting Task status using scripting

Requirement: Retrieving Task running status using BUSCOMP script

There are requirements where it is required to check in BusComp script if the Task is in running status and put the logic depending on the task running status

Solution:

Write a function on the BC as follows which will return a value to indicate if the task is running:

function GetTaskUIStatus()
{
    try
    {
        var bsTaskUI:Service= TheApplication().GetService("Task UI Service (SWE)");
        var psInput:PropertySet     = TheApplication().NewPropertySet();
        var psOutput:PropertySet = TheApplication().NewPropertySet();   
        var iReturlValue:float = 1;

        bsTaskUI.InvokeMethod("IsNotInTask", psInput, psOutput);   
        iReturlValue =  ToInteger(psOutput.GetProperty("IsNotInTask"));
    }
    catch (e)
    {
    //error handling logic
    }
    finally
    {
    // Destroy variables
    }
    return iReturlValue;   
}

Call this function where ever you want to check if Task is running as given in example below:



function BusComp_PreWriteRecord ()
{
    try   
    {
        if (GetTaskUIStatus() != 0 )
        {
        //Specific actions to be performed if Task UI is not running
        }
    }
    catch(e)
    {
    //error handling block
      }
      finally
      {
    //destroy variables
      }
     return ContinueOperation;
}
If the Task is running value returned is 0 and otherwise it is 1.

1 comments:

Anonymous said...

Lucky Club Casino Site
Lucky Club offers the best of both worlds. Read our exciting reviews, login to a casino account and start playing today! Rating: 5 · ‎7 luckyclub reviews · ‎Free · ‎iOS

Blogger Widgets