Hello,
I'm trying implement some validation on some value prompts and I have deployed my .JS file on the cognos server. I've reviewed IBM's documentation and I see that Page Module's and Custom controls use AMD modules. I'm fairly new to this topic.
Running Cognos 11.0.12
I followed the samples provided by IBM and have set a validator on one of my controls like the IBM's example.
PageModule.prototype.load = function( oPage )
{
oPage.getControlByName( "txtPhoneNumber" ).setValidator( fnTelephoneValidator );
};
When I call my "fnTelephoneValidator " function I need to check the value of another value prompt within this method. How do we get controls outside of these other modules? Do I have to set a global variable "oPage"? If so can someone show me an example? I'm struggling with syntax. Thank you
I was able to get my other controls. Now I'm unable to force a page reprompt. Can someone help with me the syntax? This no longer works within a page module
oCR.sendRequest (cognos.Report.Action.REPROMPT);
Super simple now:
oControlHost.reprompt()
or
oControlHost.finish()
Thanks for your response Paul. I'm receiving 'oContorlHost is not defined'. I believe I need to define within another module, is that correct? Below is a sample file. I've written standard JS but am new to this so if this is all wrong please let me know. Thanks
define( function() {
"use strict";
function PageModule()
{
};
PageModule.prototype.load = function( oPage )
{
oPage.getControlByName( "testId" ).setValidator( fntestId );
function fntestId( aValues )
{
//do work
if (repromptIsNeeded){
oControlHost.reprompt();
return false;
}else{
return true;
}
}
};
return PageModule;
});
It's my own fault for not having read closely enough. It looks like Page Modules don't support submitting the page. You'll have to use a custom control.
define( [], function( ) {
"use strict";
function validate()
{
};
validate.prototype.initialize = function( oControlHost, fnDoneInitializing )
{
var fntestId = function( aValues )
{
//do work
if (repromptIsNeeded){
oControlHost.reprompt();
return false;
}else{
return true;
}
oControlHost.page.getControlByName('testId; ).setValidator( fntestId );
fnDoneInitializing();
};
}
};
return validate;
});
Make sure to set the control to "No UI".