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)
FormApi
tsrookie
HI all,
Is their a simple test to see if formapi is working.
Regards
Colin
Find more posts tagged with
Comments
Johnny
FormAPI is javascript, so a simple alert would be enough
IE
<script>
alert('test');
</script>
John Cuiuli
tsrookie
Johnny,
rather than putting the test inline in the dcr I am using a file whicj I call with the script tag. the file is in the same folder as the dct. Is their a test I can do to see if it loads the file. I have been experimenting with itemHandlers with no success.
<script language="javascript" location="template-type" src="us_jobdescription.js" />
Cheers
Colin
Jens
Hi Colin,
first you can do what Johnny described and put a simple alert in your DCT. If this is coming up, FormAPI is working.
Second you can put this alert in your .js file and see what happens. If there is a lot of code in your .js file and there is a little syntax-error the code after it won't be executed, so put the alert at the beginning of the file.
Third you can attach your DCT and .js, so anybody (maybe me) will have a look at it.
Ciao,
Jens
tsrookie
Thank you Jens,
After typing this I answered my own post. Its working. I guess this can be done many ways I wonder what the most efficient is has anyone got any thoughts.
What I am doing is validating filenames, what we are finding is rather than browse for files people are typing in filenames and getting them wrong when submitted this hangs our workflow.
here is the code from the DCT
<item name="Jobs">
<replicant min="1" max="10">
<item name="Job Group Header">
<text size="55" maxlength="100" required="t">
<default>Group Executive</default></text>
</item>
<item name="Job Item">
<replicant min="1" max="100">
<item name="Short Description">
<text size="55" maxlength="100" required="t">
<default>Job Name</default></text>
</item>
<item name="Department">
<text size="55" maxlength="100" required="f">
<default></default></text>
</item>
<item name="Link">
<browser
initial-dir="/corporate/about/careers/us/jobs/pdf"
ceiling-dir="/corporate/about/careers/us/jobs/pdf"
extns="pdf,PDF,Pdf,html,HTML,Html"
required="f">
</browser>
</item>
</replicant>
</item>
</replicant>
</item>
And now the .js
function init(){
// register some handlers
IWEventRegistry.addItemHandler("/Jobs/Job Item/Link", "onItemChange", validateFileName);
}
function validateFileName(){
var fileName = IWDatacapture.getItem("/Jobs/Job Item/Link").getValue();
}
init();
Adam Stoller
Well, you *could* use a CallServer() function to have a CGI on the TS server validate the file's existance - but remember that CallServer() is *asynchronus* which means you have to do some other seemingly strange stuff to prevent standard save's and close's from working until you get a successful callback from the CGI.
I think you can find references to how to do this in a number of other posts in these forums if you don't already understand how to do it.
Alternatively, and perhaps better - is use FormAPI to make the text-field associated with the callout read-only - that way they *cannot* type in a response. Something like:
function init(){
setFieldReadOnly(IWDatacapture.getItem("/Jobs/Job Item/Link");
}
function setFieldReadOnly(item){
item.setReadOnly(true);
IWDatacapture.redraw();
return true;
}
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
tsrookie
Thanks fish,
What I did do was validate each filename/path for typos
function init(){
// register some handlers
IWEventRegistry.addItemHandler("/Jobs/Job Item/Link", "onItemChange", validateFileName);
}
function validateFileName(item){
var filePath = item.getValue();
var re = /^[\w\-\/\\]{1,}\.(txt|jpg|jpeg|gif|htm|html|pdf){0,1}$/i;
var fIsFilenameValid = (re.test(filePath)) ? true : false;
if( ! fIsFilenameValid ){
alert("Invalid filename");
return false;
}
return true;
}
init();
Adam Stoller
That's fine - but you can only check so-much that way - you can't verify that it's a valid path to a file on the TeamSite server (if it's supposed to be?) The approach I was suggesting forces (for better or worse) the user to go through the browser callout and thus ensures that the entry does not contain typos *and* is "valid" (i.e. it exists - whether or not they chose the right file is another story ;-)
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com