Page 1 of 1

running my first SHC

PostPosted: Fri Oct 25, 2013 3:08 pm
by jdbruijn
I'm trying to get my first SHC solution to work, but it does not seem to run the method that I put in the queue.
This is my code to start the SHC and the callback function:
Code: Select all
function startSHC(event) {
   var obj = new Object;
   obj.startdate = vStartDate;
   obj.enddate = vEndDate;
   obj.fs = foundset;
   
   application.output('SHC Starting ...')
   try
   {
      headless = plugins.headlessclient.createClient('CCS_headless',null,null,null);
      if(headless != null && headless.isValid()){
         application.output('SHC Started, queueing method')
         headless.queueMethod(null,'sendReports',[obj], onCallbackSHC);
         application.output('SHC method queued');
      }else{
         application.output('SHC not started.')
      }
   }
   catch(e)
   {
      application.output('SHC error: '+e.message);
   }
}

/**
* @param {JSEvent} event
*
* @properties={typeid:24,uuid:"A9B161F3-4634-4BDD-BE06-3EE1D28F2C47"}
*/
function onCallbackSHC(event)
{
   application.output('SHC - callback')
   // do some stuff
   if (JSClient.CALLBACK_EVENT == event.getType())
   {
      // handle normal execute of remote method
   }
   else if (JSClient.CALLBACK_EXCEPTION_EVENT == event.getType())
   {
      // handle exception execute of remote method
   }
   headless.shutdown()
}

The solution CCS_headless is a module of my main solution. It has 2 global methods: onOpen and sendReports. Both methods start with an application.output, the one for onOpen is shown in the log, but the one for sendReports is not.
What am I missing here?

Re: running my first SHC

PostPosted: Fri Oct 31, 2014 3:08 pm
by Ruben79
In case you didn't solve it yet: I think you have to specify the scope for the queued method, so should be something like
Code: Select all
headless.queueMethod(null,'globals.sendReports',[obj], onCallbackSHC);
//or
headless.queueMethod(null,'scopes.yourScope.sendReports',[obj], onCallbackSHC);


Also, I think you cannot pass in foundsets as an argument so you might want to try running it without arguments first.