Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Question/Problem with CGITask
dootndo2
I am using Teamsite 6.1 with sp2 and spent the better part of the day trying to figure out how to successfully utilize this cgitask.
What I am looking to do:
1. The user is submitting the content and the workflow kicks off an email task. -- WORKING
2. The person gets the email and then goes to the task. -- WORKING
3. The person clicks on the task and the CGI page is rendered. -- WORKING
4. The person selects information from dropdownlists and then clicks on one of the submit buttons. -- WORKING
The submit is supposed to send the information back to the form, right? This I don't know. Or does it send the variables back to the workflow?
What I want to happen is to have some logic that parses out the information returned and then do something based upon those decisions.
The CGI page should send back the users selected email addresses of users to receive the next notification. Based on what was selected, the next task should be activated accordingly. I am able to receive the Interwoven variables (taskid, wfid, etc.) in my CGI.
Here are my questions:
1. Does the post back actually send the values back to the WFT form to be evaluated?
2. If 1 is yes, then how do I access those variables?
3. If 1 is no, then how do I call certain successor items through the CGI page?
On a side note, when items are built dynamically, are they static after instantiation or is each component dynamically built at each point of the workflow (each task)?
Thanks to all.
Find more posts tagged with
Comments
iwovGraduate
... then how do I call certain successor items through the CGI page?. ...
Theres a sample CGI task shipped with TeamSite. Have you looked at that ?
Have you looked at the documentation ? KBs ? Searched the forums ?
Also look at perldoc TeamSite::WFtask
If you have and you are still not able to get it to work, post your code (wft and cgi) with relevant details about it along with things that you have tried so far.
I assume you are talking about choosing a task transition based on certain conditions from a cgitask of a workflow. Correct?
jbonifaci
I agree with Samir, posting your code or snipets of your code will help get you better answers. It will also probably get you a sarcastic comment or two about trying to get others to do your work for you. That said, your cgi will post the data wherever you tell it to. You can post it to another cgi, or back to the same cgi. I prefer to post back to the same cgi rather than having multiple, but that's your call. As far as transitioning, it is done the same way you would transition an external task (either iwcallback or (TeamSite::WFtask)->CallBack). Hope this helps.
dootndo2
Thanks for your replies. I have spent a few days now reading and researching this topic. It seems that most folks seem to be using TAG_CGI and alike. I am posting back to the IPL that is called in the CGITask. The problem is that even if I post back to the same IPL, how do these values get sent back to the workflow to manipulate?
Also, the code that I am working on does not run immediately nor does it start. I think this situation is somewhat unique and I cannot find any documentation regarding this.
I am at home now, but will post some code in the morning.
Still a newbie. Thanks for your replies.
jbonifaci
You can modify the workflow by using command line tools, TeamSite::WFworkflow or TeamSite::WFtask. Read up on those and you should get your answers.
iwovGraduate
As mentioned by Jeff you'll can use the WF API to pass the variables back to the workflow and manipulate it.
Can you explain what exactly do you mean by "does not run immediately" ? See documentation on immediate=t attribute of cgitask.
From what you have mentioned so far, I don't see anything unique about what you are trying to do. Perhaps you can provide more explanation.
kshitiz
The submit is supposed to send the information back to the form, right? This I don't know. Or does it send the variables back to the workflow?
You can set the workflow variables in your CGI task and use them accordingly.
What I want to happen is to have some logic that parses out the information returned and then do something based upon those decisions.
A simple external task after your CGI task can parse the set WF variables and make the decisions and transitions to next tasks.
Kshitiz Sharma
BT Wholesale | CMS
Mahindra British Telecom
Adam Stoller
There's no need to have an externaltask after a cgitask - your cgitask script can do pretty much everything an externaltask script can do - with the addition of being able to provide a UI.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
dootndo2
Thanks all for your replies. I posted the following code as I said that I would last night. All of the suggestions have been very helpful so far.
As a side note: I am not looking for someone to write code for me, just trying to use this forum as a learning tool and a means to reach out to experts in this application. Thanks for all your help in advance.
We are doing tasks prior to the CGI task and the immediate=t is not going to work for us. I will work on the CGI code today. The code looks something like this:
I tried to simplify the code for brevity.
[WORKFLOW CODE]
<workflow name = "Workflow" owner = "__TAG__('iw_user');" creator = "__TAG__('iw_user');" description = "Workflow" >
<variables>
<variable key="parentTaskId" value="" />
</variables>
<!-- STEP 1 Email to the 1st group -->
<externaltask name="Email1" owner="__TAG__('iw_user');" description="" start="t">
<areavpath v = "__TAG__('iw_workarea');" />
<successors>
<successorset>
<succ v = "Step2"/>
</successorset>
</successors>
__INSERT__(getEmailList("group", "
@group"))
;
__INSERT__($iw_selected_files);
</externaltask>
<!-- END STEP 1 -->
<!-- STEP 2 Step2 task to assign groups to review -->
<cgitask name="Step2" start="f" owner = "__TAG__('iw_user');" description="" immediate="f">
<areavpath v = "__TAG__('iw_workarea');" />
<successors>
<successorset description = "Step3">
<succ v = "Email_2"/>
</successorset>
<successorset description = "Step4">
<succ v = "Fix" />
</successorset>
</successors>
<command v="cgi_test.ipl"/>
</cgitask>
<!-- STEP 3 Email Compliance and set up task -->
<externaltask name="Email3" owner="__TAG__('iw_user');" description="" start="f">
<areavpath v = "__TAG__('iw_workarea');" />
<successors>
<successorset>
<succ v = "Step4"/>
</successorset>
</successors>
__INSERT__(getEmailList("group2", "
@group2"))
;
<activation>
<or>
<pred v = "Step2"/>
</or>
</activation>
</externaltask>
<!-- rest of workflow from here -->
[END WORKFLOW]
In this step 3, the email notification should be sent to individuals or groups as depicted in the CGITask (dropdown lists specifically).
[CGI]
use TeamSite::CGI_lite;
use TeamSite::WFtask;
use TeamSite::WFworkflow;
$|=1;
my($cgi) = TeamSite::CGI_lite->new();
$cgi->parse_data();
my($taskid) = $cgi->{form}{iw_taskid} || $cgi->{form}{task_id};
my($task) = TeamSite::WFtask->new($taskid);
my($wfid) = $task->GetWorkflowId();
print<<"END";
Content-type: text/html; charset=utf-8
<html>
<head>
</head>
<body>
<for>
<input type='radio' name='selection' value='group'> Group </input>
<input type='radio' name='selection' value='individual'> User </input>
<select name='EmailRecipient'>
<option value='0' selected>-- Please select from Individuals--
<option value='1' > Person1
<option value='2' > Person2
</select>
<input type='submit' value='Send Email Notification' onClick='javascript:window.close()'>
</form>
</body>
</html>
END
# I know here callback 1 for success and to activate next item and 0 for fail or not to activate. Not sure which way I want to go with this yet.
$task->CallBack(1, "Finished CGI Task.");
[END CGI]
Adam Stoller
I tend to write my cgi scripts in such a way that I can have them call themselves repeatedly to perform various functions - from a high-level pseudo-code view:
parse_cgi_data();
if (****_form_variable_is_set){
do_yyy();
}
elsif (yyy_form_variable_is_set){
do_zzz();
}
elsif (zzz_form_variable_is_set){
callback_and_close_window();
}
else {
first_time_through();
}
...
You need to make sure you pass all existing form variables as hidden variables through the recursion.
You need to make sure you account for this in browsers like IE where it seems much more prone to take a scalar form variable and turn it into an array of identical values - requiring something like:
$formvar = pop(
@$formvar)
if (ref($formvar) eq "ARRAY");
There's probably some other stuff - but that's how I'd look at designing it to being with.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
jkm
Hi Adam,
I am implementing something as in this thread. I have two queries to post back the values in the same cgi script.
1. Is this necessary to use CGI_lite package? Doesn't this work with CGI becasue I was trying to post the values using CGI module but it wasnt working and when I changed it to cgi_lite its able to post back the values.
2. I am trying to post the values of checkbox using this method but its showing me only values of the checkboxes which ever i selected. But I want to see the values of the all the checkbox wheather its been selected or not and then on decision of tht i will run my other functions. Why its not showing me the values of unchecked boxes.
Here is the sample code snippet i was trying .
if ( $recursive ) {
foreach my $key (sort(keys %{$cgi->{form}})) {
if (!ref $cgi->{form}{$key})
{
print LOG "scalar: ", $cgi->{form}{$key}, "\n";
}
else {
print LOG "array:$key \n @{$cgi->{form}{$key}} \n";
}
}
my
@filelist
= @{$cgi->{form}{FileSelect}};
print LOG "
@filelist"
;
&print_header;
print "<br/>
@filelist"
;
close LOG;
}
jkm
forgot to mention env is
Windows 2003 + TS6.5 :-)
jkm
Any idea how can we achieve the second part .. I checked couple of other examples and tried a script in normal cgi .. even in that i am not able to get the value of unchecked checkboxes.
jbonifaci
I'm fairly certain that unselected values are not returned in the post data. Only values selected are passed.
~Jeff
Adam Stoller
Not sure - if the checkboxes are (can be?) defined with explict values for both checked and not-checked - you'll probably be able to get them. Otherwise, I'm not sure there's much you can do other than perhaps include a hidden field that contains the list of all possible checkboxes and use that to compare against the list that have values in the form data.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
jkm
thanks for your comments ...
Fish, i have given explicit values to all the check boxes but it doesnt return anything
Its quite weird that unselected check boxes are not posted in CGI .. I can implement this always by putting the list of values in a file while populating check bixes or something and then compare but it makes the code to be really dirty .. to do a simple task such a dirty process ..
JonathonG
Checkboxes are a form of data entry. Typically, the point is that the user is going to select more than 1 of them, but probably not all. In a typical usage scenario, only the selected check boxes matter, because the unselected one were deemed unimportant by the user. Thus, the browser only posts the values that are selected.
I'm not sure what requirement would be driving you to need to know the values of the unselected checkboxes from your form processing code, but I'd suggest that a design that depends on seeing all of the values probably needs to be re-thought.
Jonathon
Interwoven Developer
Allstate, Inc.
jkm
I would defer to the arguement that only checked check box are required..
I have a list of files in my cgi form. I want to process the checked files with my templates and unselected files to delete. To perform these two actions I need to know selected and unselected files
JonathonG
While I think that would be a confusing user interface (the user is expected to understand that by doing nothing, they are choosing to delete), the easiest way to solve the issue is to create a hidden form variable with your CGI that contains a list of all the files. Then, you can process this list against the list of the selected files to differentiate.
Jonathon
Interwoven Developer
Allstate, Inc.