How do I get job variable.

SriniYA
edited July 20, 2021 in TeamSite #1
I have a workflow with 10 external tasks. In the second external task I am creating two job variables. I would like to get these variables in third external task.

I tried with these command. It works from command line. But doesn’t work from the workflow.

$iwhome/bin/iwjobvariable -g FormatReviewUsers $wfid

$workflow->GetVariable($option_step);

and also I used $workflow->Refresh() in the second workflow.

Any Ideas?

Thanks

Comments

  • Try wrapping quotes around your argument for GetVariable.

    Dave Smith
    Sr. Software Engineer
    Nike, Inc.
    (503) 671-4238
    DavidH.Smith@nike.com
  • I tried, But it doesn't work
  • Maybe if you attached your externaltask script that isn't working properly, it would help debug the problem.

    Dave Smith
    Sr. Software Engineer
    Nike, Inc.
    (503) 671-4238
    DavidH.Smith@nike.com
  • #!/bin/iwperl
    use TeamSite::WFworkflow;
    use TeamSite::WFtask;
    use TeamSite::Config;
    use strict;

    my $option_step_name = $ARGV[0]; # job variable
    my $wfid = $ARGV[1];
    my $taskid = $ARGV[2];
    my $workflow = new TeamSite::WFworkflow($wfid);
    my $task = new TeamSite::WFtask($taskid);
    my $iwhome = TeamSite::Config::iwgethome();


    open (LOG, ">>$iwhome/custom/logs/intranet/ta_check_for_options.log");

    my $cmd="$iwhome/bin/iwjobvariable -g '$option_step_name' $wfid";
    my $test =`$cmd`;
    print LOG "\ncmd=$cmd\n\nTEST2: $test\n\n";

    print LOG "DEBUG:" . $workflow->GetVariable('$option_step_name');
    print LOG "\nERROR: $?\n";

    close (LOG);
    exit;
  • And what does your log output look like?

    Dave Smith
    Sr. Software Engineer
    Nike, Inc.
    (503) 671-4238
    DavidH.Smith@nike.com
  • cmd=/www/negril3/interwoven/iw-home/bin/iwjobvariable -g 'FormatReviewUsers' 8460

    TEST2:

    DEBUG:
    ERROR: 0
  • So if I understand correctly, you can execute the command:

    /www/negril3/interwoven/iw-home/bin/iwjobvariable -g 'FormatReviewUsers' 8460

    from the command line and it works, but it doesn't work within this externaltask script, nor does GetVariable. Correct? That is weird. How are you creating the workflow variable? Please post the entire script and can you try doing a GetVariable in the same script where you create the variable and log whether it works?

    Dave Smith
    Sr. Software Engineer
    Nike, Inc.
    (503) 671-4238
    DavidH.Smith@nike.com
  • Yes, It works from command line. Doesn’t work from externaltask.

    I am creating variables like this

    my $out = $workflow->CreateVariable("FormatReviewUsers", "$FormatReviewUsers");
    print "AAAAA out: $out";
    $workflow->CreateVariable("EditorialReviewUsers", "$EditorialReviewUsers");
    $workflow->CreateVariable("FormalApprover", "$FormalApprover");
    $task->Refresh();
    $workflow->Refresh();
    print LOG $workflow->GetVariable("FormatReviewUsers");

    the last command is getting job variable. But I want to get these job variables in the other external task.
  • Well I'm stumped. You shouldn't need to perform any refreshes during this process. Have you tried hardcoding the variable name in the GetVariable command in the second externaltask instead of using a variable? I assume you got the correct value printed in the log when you added the GetVariable to the externaltask that creates the variable?

    Dave Smith
    Sr. Software Engineer
    Nike, Inc.
    (503) 671-4238
    DavidH.Smith@nike.com
  • i tried hardcoding the variable name. I even tried to create job variable using iwjobvariable CLT. It doesn't work
  • OK, last request, because I think the Interwoven folks will ask for this anyway. Can you attach your job spec for the workflow that is being used to call these externaltasks and note which task is the one setting the variable and which task is the one that's attempting to read it?

    Dave Smith
    Sr. Software Engineer
    Nike, Inc.
    (503) 671-4238
    DavidH.Smith@nike.com
  • I sent you an email

    Thanks
    Srini
  • Would you mind posting the solution as I have had trouble w/ mine as well.

    Michael D. Ender

    p: 989.638.4163
  • A bit of a shot in the dark but.......
    I've had problems writing to wf variables from cgi tasks when ran with out the use of the cgi wrapper (impersonates the task owner user). However your scripts are external tasks and should run fine. the owner of the task is okay in terms of security permissions ?
  • my $cmd="$iwhome/bin/iwjobvariable -g '$option_step_name' $wfid"; my $test =`$cmd`; print LOG "\ncmd=$cmd\n\nTEST2: $test\n\n"; print LOG "DEBUG:" . $workflow->GetVariable('$option_step_name'); print LOG "\nERROR: $?\n";

    Uhm - the code above shows you using single-quotes ('...') around a variable ($option_step_name) - single-quotes prevent the variable from being interpolated so the result is that you are literally asking for the value of a variable named $option_step_name - which I'm pretty sure was not your intention.

    Have you tried replacing those single quotes with double-quotes?

    Also - what version of TeamSite are you using on what platform?

    --fish
    (Interwoven Senior Technical Consultant)
TeamSite Developer Resources

  • Docker Automation

  • LiveSite Content Services (LSCS) REST API

  • Single Page Application (SPA) Modules

  • TeamSite Add-ons

If you are interested in gaining full access to the content, you can register for a My Support account here.
image
OpenText CE Products
TeamSite
APIs