Home
TeamSite
Setting multiple values on a DCT from CGI callout
System
I am hoping to create a CGI callout that can set multiple values on the DCT instead of setting just the one. Usually whenever there is a CGI callout such as a calendar it sets the value for a single field. However I wish to run a CGI script that reads a few values in from the DCT and then displays them. Then after these values have been edited, then it should save these to the DCT.
I am having trouble getting the usual FormAPI to work, as I cannot seem to be able to get the script to run in the DCT window. Any ideas?.
If I cannot use FormAPI within the CGI script then how can I get/set the values in the DCT?
Many thanks!
Find more posts tagged with
Comments
Migrateduser
Always the way that as soon as you post a question - you manage to find the answer...
If you use:
api = opener.parent.getScriptFrame();
api.IWDatacapture.getItem("/container/name").setValue("this works");
api.IWDatacapture.getItem("/container/name2").setValue("this works as well");
etc
Then it populates the fields correctly!
jkm
Hi ,
I am also running into similar problem .. trying to set multiple values from cgi callout to my DCT ..but not able to get through .. can you please provide more specific steps to achieve this ..
jkm
forgot to metiont ... Env is TS 6.5 + Windows 2k ..
Adam Stoller
Look at DanMint's posted solution again.
Look at the FormAPI manual [again].
Once you have a handle on the FormAPI layer within your CGI code's javascript section - it's pretty easy to access any field in your DCT (unless you're dealing with multiple-tabbed/page DCTs)
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
jkm
hi ghoti,
this is a just a sample code snippet
<script language='JavaScript'>
function dis(myForm){
alert("Hello2");
Article/NewsLetter/test.value="this works";
alert("Hello1");
opener.top.datacapture.refreshForm("Article/NewsLetter/test");
}
</script>";
On click of select button this function is calls and then I am trying to set a test value but this line seems to be some problem
Article/NewsLetter/test.value="this works"; as I am not able to see the alert after tht and neither value in the DCR
can you point out where i m doing wrong ?
jkm
any assistance on this please ?
Adam Stoller
You're clearly not doing a very good job of reading and understanding the earlier post - so let me see if this helps:
<script language='JavaScript'>
api = opener.parent.getScriptFrame();
function dis(myForm){
alert("Hello2");
api.IWDatacapture.getItem("
Article/NewsLetter/test
").setValue(
"this works"
)
;
alert("Hello1");
opener.top.datacapture.refreshForm("Article/NewsLetter/test");
}
</script>";
This is assuming that "
Article/NewsLetter/test
" correctly identifies a non-replicant item in your DCT.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
jkm
Thanks ghoti .. I was putting api = opener.parent.getScriptFrame(); in my function seems to be becasue of this it was failing
I am able to set the values of Non replicant fields but for replicant fields its not working .. I am taking iw_item_name for replicants as well and trying to set the same .. but no value is appearing in that case .. how to fix tht replicant part
Adam Stoller
I suggest you spend a bit more time reading the FormAPI manual and/or researching information in these forums - to learn how to properly address replicant items. Once you understand how to formulate the address of the replicant items - you can use that information along with the previous example, to access them via your javascript code in your CGI script.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
jkm
sorry ghoti .. I know I need to work more on FormAPI .. I searched the forum for replicants
but would be really helpful if you give me any code snippet at this point of time ... to meet my deadly deadlines ;-)
jbonifaci
opener.parent.getScriptFrame() should not break your javascript if you are using a datacapture cgi callout. The code Adam provided should work assuming your field name is valid. I would suggest reading up on formapi if you are still having problems. You can access the help with the following url:
http://<YourTeamSiteServer>/iw/help/tst/formapi/
.
~Jeff
jkm
hi guys ..
code provided by ghoti worked for me and now to set the values of replicants i
api.IWDatacapture.getItem("Article/NewsLetter/ArticleDetails[$replicant]/ArticleURL ").setValue("this as works");
where $replicant has value 0,1, wat ever depending upon iw_item_name
but its not able to push the values in DCT :-(
Adam Stoller
Why don't you try some things out - post what you tried, how you debugged what you tried, what you saw in your debugging - and then we can talk about how to revise your code.
If you figure it out yourself it will make much more sense to you now, and in the future.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
jbonifaci
The item name passed for a replicant is 0 based. When using formapi item names for replicants are 1 based. So if the replicant name you get is 0, you need to reference replicant 1 in formapi. If it is 1, you need to change it to 2, etc.
~Jeff
jkm
I think in call out item names are different .. i tried another hack using iw_call_back and stripped the replicant number...which in my case coming 11 == for first replicant
and passed the same .. and I tried 1 as well both ways as suggested by Jeff..
First thing i want to make sure to access the replicant this syntax is correct .. i just referred FormAPI doc in that they were referring replicant in the below manner
api.IWDatacapture.getItem("Article/NewsLetter/ArticleDetails[$replicant]/ArticleURL ").setValue("this as works");
ghoti, should be gud if I know the debug log or something for this
jbonifaci
Well, you have an extra space at the end, which is going to give you a problem. Other than that it looks good, assuming all of the field names are correct.
~Jeff
jkm
yes, even I noticed and removed it already
iw_callback_var=Article/NewsLetter/ArticleDetails/11/ArticleURL so I dont
iw_item_name=Article/NewsLetter/ArticleDetails/0/ArticleURL
so field values I dont have any doubt much now ...
but stil its just not appearing ...ufffffffff .. can you suggest how do I track where is this value going to debug this ?
jkm
it worked .. some other debug JavaScript error .. cheerss .. thanks guys
jbonifaci
try this, read the item name in your perl like this:
use CGI;
my $CGI = new CGI;
my $itemName = $CGI->param('iw_item_name');
$itemName =~ s|/(\d+)/|'['.eval($1+1).']/'|eg;
Or however you want to read the name in, but the key part is that I'm transforming the item name into the format that the formapi will recognize. Then in your javascript do this:
opener.parent.getScriptFrame().IWDatacapture.getItem("$itemName").setValue("Test Value");
~Jeff
amar_maheshwary
Hi Guys, one more assistance is required .. In callout we can get the replicant number using 'iw_item_name' hack but for FormAPI I didnt see any method to get the replicant item number becasue they are always referring to [3][5] or something directly from the xml .. If I want to make invisible all the elements of a container with replicants then I need to know the last replicant count ... so that I can run a loop ... how to get that as well ?
jbonifaci
The best option would be to use getChildren on the replicant and then you don't really care about the number, as you just iterate through the array.
~Jeff