I have a good idea, but...

Post Reply
Clive Andrews
Member
Posts: 85
Joined: Thu Jun 23, 2011 11:41 am

I have a good idea, but...

Post by Clive Andrews »

OK, here's a random thought....



As jobs get preflighted, checkpointed and decisions made - various email are sent to the CSR's. That is all in place and working.



When a Repro operative logs onto a job, his name is taken as a value in the MIS database (and shows in our Crystal reports etc)



Now:



Can anyone think of a way to make an email wait until it's destination address is populated.



Sooooo....



All the relevant job emails are copied from the CSR versions, prepped for sending, but will wait until the Op logs into the job, his name arrives in the appropriate MIS field. When that field is "not empty" we can copy that value (poss do a lookup to cross ref operator with email address) - and then post the Repro Op all the relevant data for the job.



This would be a great boost and use to my guys - but it's the empty email field is the tough one.



Thoughts anyone (I haven't started on it yet, just garnering your mental reserves)
Clive Andrews
Member
Posts: 85
Joined: Thu Jun 23, 2011 11:41 am

I have a good idea, but...

Post by Clive Andrews »

Follow up - I'm thinking maybe I could use a "Hold Job" or a "Sort Job" before the email, then query my database - once the condition is fulfilled, the email get's sent...
dkelly
TOP CONTRIBUTOR
Posts: 658
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

I have a good idea, but...

Post by dkelly »

Clive, do you have a SQL query to retrieve the Repro Op's email address from the MIS database?
freddyp
Advanced member
Posts: 1023
Joined: Thu Feb 09, 2012 3:53 pm

I have a good idea, but...

Post by freddyp »

It can be done with a script element in front of the "Mail send" which behaves like "Hold", but instead of waiting for a defined length of time it waits until a condition is true before moving on to the next element in the flow. It is not that difficult.
Clive Andrews
Member
Posts: 85
Joined: Thu Jun 23, 2011 11:41 am

I have a good idea, but...

Post by Clive Andrews »

@Dwight - I'm on the case with that (well our resident MIS Guru is)



@freddyp - I'm not that good at scripting, all self taught, so I was hoping just to use a condition on a connector...
dkelly
TOP CONTRIBUTOR
Posts: 658
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

I have a good idea, but...

Post by dkelly »

Clive, here's a quick sketch of how you could do it.



// WaitForEmail

//

// Written by Dwight Kelly <dkelly@apago.com>

// Copyright 2012 by Apago, Inc. - All rights reserved



function jobArrived( s : Switch, job : Job )

{

var datasource = new DataSource();

var dsn = "theDataSource";

datasource.useConnection(dsn);

if (datasource.isConnected()) {

var stmt = new Statement(datasource);

stmt.execute("SELECT e_mail FROM thetable.thefield WHERE x=y");

if (stmt.isSuccess()) {

stmt.fetchRow();

var emails = new Array();

emails[0] = stmt.getString(c);

job.setEmailAddresses(emails);

job.sendToSingle(job.getPath());

}

datasource.disconnect();

}

}



Learn advanced Javascript for Switch

Full day seminar during Graph Expo in Chicago, Oct 8th, 2012

http://www.brownpapertickets.com/event/264833



Dwight Kelly

Apago, Inc.

dkelly@apago.com

Back to top
freddyp
Advanced member
Posts: 1023
Joined: Thu Feb 09, 2012 3:53 pm

I have a good idea, but...

Post by freddyp »

@Dwight: your script will take the right decision, but it will continue immediately. What Clive wants is that it waits until the correct value is available in the database. So you will have to put a master loop in the script with an s.sleep(x) to avoid draining the CPU.



@Clive: it is indeed not quite as simple as a condition with a variable because that is evaluated immediately and the flows continues or fails immediately. I tried making a generic script that would take the condition from outside the script as a parameter. I failed so far, because I have not found a method to force the condition to be re-evaluated with every cycle of the loop. I am stuck with the initial value when the script is called the first time. So you have to put the condition inside the script as well as Dwight has done, but then with a loop.
dkelly
TOP CONTRIBUTOR
Posts: 658
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

I have a good idea, but...

Post by dkelly »

Hi Freddy, my script just returns if the record doesn't exist leaving the job unchanged. Switch won't call the script again until the time between scans has passed (in Prefs).



However, a better way would be to write the script as a timerFired() instead of jobArrived(). I was just trying to keep it simple for Clive. ;-)
freddyp
Advanced member
Posts: 1023
Joined: Thu Feb 09, 2012 3:53 pm

I have a good idea, but...

Post by freddyp »

Hi Dwight,



indeed, I overlooked that. Yours is certainly the easiest approach.



I played around with TimerFired() during my tests, but there too I could not get it work with an external condition in order to come to a generic solution. The advantage of TimerFired() would be that you can set the interval independent of the Prefs and that you can time out. It was based on those aspects that my thinking was directed towards looping inside the script, because then you can control that. But it makes the script a bit longer.



I think it could be an interesting use case to let a connection wait until a condition is met. I will log it as a feature request, but with a low priority. There is the case that Clive described, but I cannot think of any other scenarios, other than the cases where you want to do something based on a time slot, but that is standard Switch functionality.



If anyone knows of scenarios where such a "trick" would be useful, I would gladly hear about it.
dkelly
TOP CONTRIBUTOR
Posts: 658
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

I have a good idea, but...

Post by dkelly »

Earlier I posted a script that acted as a source. It was a timerFired() script that checked for new orders in a database, created XML for Apago PDF Constructor and marked the order as processed. It would be nice if the script could be called by a database trigger instead of a fixed timer.
Clive Andrews
Member
Posts: 85
Joined: Thu Jun 23, 2011 11:41 am

I have a good idea, but...

Post by Clive Andrews »

Well, I'm certainly watching this with interest, seems like we have 2 good brains on the case. I've been playing with a Demo copy of the Database configurator - trying to drill down to the fields I need.



I'm also looking at getting access to the Apogee database, again - with a similar idea. We have a routine that restores files if there is a standing job ID in the JDF. If I could make CHILI wait until the job shows as restored, then it can fire amended pages in, auto placed in a runlist (a simple page number prefix). I have to set Apogee to overwrite with new files - so I want to make sure Switch/CHILI waits until the previous file is restored...



(we haven't bought CHILI yet, a lot depends on me making this work - and I am still at the proof of concept/dummy website stage)
dkelly
TOP CONTRIBUTOR
Posts: 658
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

I have a good idea, but...

Post by dkelly »

Clive, I've just wrapped up a complete Magento/CHILI/Switch workflow. Not getting a lot of sleep lately. ;-)



Also, wrote a Switch script that automatically archives jobs once the MIS system says the job has shipped.
Clive Andrews
Member
Posts: 85
Joined: Thu Jun 23, 2011 11:41 am

I have a good idea, but...

Post by Clive Andrews »

dkelly wrote: Clive, I've just wrapped up a complete Magento/CHILI/Switch workflow. Not getting a lot of sleep lately. ;-)



Also, wrote a Switch script that automatically archives jobs once the MIS system says the job has shipped.


You have been burning the midnight oil Sir - wish I was "Stateside" so I could attend the Java course - that is where my skills are lacking - I'm not short on ideas by any means...
Post Reply