COGNOiSe.com - The IBM Cognos Community

IBM Cognos Analytics Platform => Cognos Analytics => Reporting => Topic started by: rteruyas on 01 Feb 2018 09:15:00 AM

Title: Custom control to validate 2 prompt dates
Post by: rteruyas on 01 Feb 2018 09:15:00 AM
Hey guys, I'm trying to follow this tutorial
http://www.pmsquare.com/main/blog/cognos-analytics-custom-javascript-date-prompts-datasets/

But seems that I'm not able to import the "moment.js" library
The error message I get when running the project is

Error: Module name "moment.js" has not been loaded yet for context: _. Use require([])

Let me know if you need more detail
Thanks in advance!

Title: Re: Custom control to validate 2 prompt dates
Post by: rteruyas on 01 Feb 2018 09:29:51 AM
Nevermind, just figured it out.
I need to make an asynchronous call when using define

----------

define( ["/samples/javascript/moment.js"], function( moment ) {
"use strict";

function FromToDateValidation()
{
};

FromToDateValidation.prototype.initialize = function( oControlHost, fnDoneInitializing )
{
  var o = oControlHost.configuration
    , NO_VARIABLE_DEFINITION_FOR_MOMENT_HERE
    , secondaryRun
    , dynStartDate
    , dynEndDate
    , datastores;
   
  this.ctrlFrom = o ? o["fromPrompt"] : 'fromDate';
  this.ctrlTo =   o ? o["toPrompt"] : 'toDate';
  secondaryRun = sessionStorage.getItem(this.ctrlFrom+'secondaryRun');