How do I add multiple file to the menu item workfl

SriniYA
edited July 20, 2021 in TeamSite #1
Hi

We are using TeamSite5.5.2 SP3 on Solaris. I would like to create new workflow and add multiple file to the workflow using Menu item.
I am able to create a new workflow from menu item. After invoking the new workflow, no files are attached. Anybody knows, what i can do?

I have defined

#=====================================================================
# Define the file list
#=====================================================================
my @submit_file = (); # files sorted in unencoded
if (__ELEM__('iw_file')) # form, then html-encoded
{ # by hand via CGI_lite
@submit_file = map { TeamSite::CGI_lite::escape_html_data($_);
} sort __VALUE__('iw_file');
}

and I am adding files using

foreach my $mv_file (@files) {
push (@{$wft->{tag}{'iw_file'}{value}}, $mv_file);
}


I have files in the @files like
My @files = (“dir1/test1.htm”, “dir1/test2.html”); and my areapath is /default/main/test/WORKAREA/content


Thanks
Srini

Comments

  • Have you taken any training in workflow development?
    Have you read through the workflow tutorial document?
    Have you looked at any of the out-of-the-box workflows that do, at least in regard to this part, what you want?

    If you've gone through the tutorial document and you've looked at other workflows and still can't figure out how to do this - please consider taking a workflow development training class (I believe there are web-based courses available from Interwoven for this purpose).

    If you've done all that, and still can't figure out how to do this - you can post again - but you might be better off hiring someone to come in and do it for you.

    --fish
    Senior Consultant, Quotient Inc.
    http://www.quotient-inc.com
  • Hi Fish,

    I would like to create that workflow using custom script. I have taken training in workflow development and checked workflow tutorial document. I am able to create the workflow. But not able to add multiple files using custom script. Here is my script


    sub doCreateMoveWorkflow($$$) {
    my $branch_name = shift;
    my $wa_path = shift;
    my $file_array = shift;
    my @selected_files = @{$file_array};


    my $wft = TeamSite::WFtemplate->new(template => "$iwhome/local/config/wft/test/move_file_to_prod.wft");

    $wft->{tag}{"iw_branch"}{value} = "/default/main/$branch_name";
    $wft->{tag}{"iw_workarea"}{value} = "$wa_path";
    $wft->{tag}{"iw_home"}{value} = $iwhome;
    $wft->{tag}{"iw_use_defaults"}{value} = "true";
    $wft->{tag}{"iw_user"}{value} = "testuser";
    $wft->{tag}{"iw_debug_mode"}{value} = "false";
    $wft->{tag}{"iw_desc"}{value} = "Move files to Prod";
    $wft->{tag}{"iw_output_file"}{value} = "$iwhome/tmp/foo.xml";
    foreach my $mv_file (@selected_files) {
    push (@{$wft->{tag}{'iw_file'}{value}}, $mv_file);
    }


    my @tags = $wft->get_tags();
    my $error = $wft->get_error_message();
    if( "" ne $error ) { print LOG "ERROR creating workflow job: $error"; return; }

    # get xml spec
    my $wf_spec = $wft->get_workflow();

    # submit the spec to create the job
    my $wf_system = TeamSite::WFsystem->new();
    my $wf = $wf_system->CreateWorkflow( $wf_spec, "$iwhome\/tmp\/cci\/workflow" );

    my $valid = $wf->IsValid();
    $error = $wf->GetError();

    if ((!defined $wf) || !$wf->IsValid() || $wf->GetError()) {
    print LOG "ERROR creating workflow job: $error";
    return;
    }

    # invoke the job
    $wf->Invoke();
    }
  • Ah - okay - that's a horse of a different color.... was iwwft_instantiator.ipl included in SP3? (I can't remember, I'm working primarily with SP2 and I know it isn't there) - if so - you might find the entire thing easier to do by creating the wft and using iwwft_instantiator.ipl ... however ...

    In 552Sp2 we had a similar issue where we were having a submit workflow instantiate a newjob workflow - using code similar to that which you posted above but we could never seem to get the iw_file tag to do what we wanted, so instead, we created a new tag variable called 'got_files' and set it to be a comma-delimited list of pre-selected files. Within the actual wft code we split it up with a routine like this: sub preselected_files_xml {
    my $xml = '';
    my $got_files = __VALUE__('got_files');

    if ($got_files) {
    my @files = split/,/,$got_files;
    $xml .= "<files>\n";
    foreach my $file (@files) {
    $xml .= qq(\t<file path="$file" comment="__TAG__(iw_desc);"/>\n);
    }
    $xml .= "</files>\n";
    }
    return $xml;
    }
    Then all you need is an __INSERT__(preselected_files_xml()); in your start task(s) where appropriate. Chances are there is a way to do this correctly with the iw_files tag - but once we got the above solution we never looked back...

    Hope that helps

    --fish
    Senior Consultant, Quotient Inc.
    http://www.quotient-inc.com
  • Thaks fish

    It is working
    Srini
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