Topic Options
#40404 - 08/15/12 12:09 PM PressTalk Before Not Working
erm Offline
OL Newbie

Registered: 08/24/10
Posts: 14
I'm attempting to build a form with global conditions that use the 'advanced' condition type. I want to include global variables within the condition presstalk code. My goal is to set the value of these global variables using the Document "PressTalk Before" code section and then have the global condition react appropriately. I only want it to evaluate once at the start of the form.

So far it is working perfectly in Design with Preview. However, it does not work once I export it to a workflow and run it there as it would in production.

PressTalk Before (document level):
Code:
State := expandstring('%{State}')

&Queue := @(10,1,3)
&PrintNum := @(10,4,4)

if(&State = 'KS')
	if(&Queue = 'ABC')
		&PrintNum := '1'
	endif()
endif()


Advanced Condition Code:
Code:
=((&Queue='ABC') and (&PrintNum='1'))


Based on my testing so far, the Document PressTalk Before code gets the %State variable from my workflow just fine, but then nothing else works--my global variables (&Queue and &PrintNum) are empty. This means that my conditions aren't ever being set and evaluated correctly. Any ideas or suggestions? What am I doing wrong?

Thanks!

Top
#40408 - 08/15/12 02:03 PM Re: PressTalk Before Not Working [Re: erm]
Raphael Lalonde Lefebvre Offline
OL Expert

Registered: 10/14/05
Posts: 3645
Loc: Objectif Lune Montreal
erm,

Are you using global variables in global conditions?

EDIT: Ok, to correct my post, global variables are actually created before global conditions. However, they are evaluated before the data emulation. Therefore, if you use global variables that uses values from your data to make global conditions, it will not work well.

For conditions on global variables, you can either type your conditions in the basic attributes of the pages and objects that needs it, or you could make a global boolean function that returns either True or False based on your comparison's result.

Example of a global function:
Code:
function @MyCondition():Boolean
  define(&res, boolean, False)
  if((&Queue='ABC') and (&PrintNum='1'))
    &res := True
  endif()

  &Result := &res
endfunction()



Everywhere you want to use it, you put it in the basic attributes of your objects:

=@MyCondition()

If you need to change it, you just need to change the global function's code, so in the end, it will work much like a global condition, except it can use global variables without issues.

Regards,
Raphaël Lalonde Lefebvre


Edited by Raphael Lalonde Lefebvre (08/15/12 02:57 PM)

Top
#40427 - 08/17/12 10:33 AM Re: PressTalk Before Not Working [Re: Raphael Lalonde Lefebvre]
erm Offline
OL Newbie

Registered: 08/24/10
Posts: 14
Thank you for the suggestion. I've moved my conditions into global functions and they appear to be working. However, I'm still having a problem getting my global variables to initialize properly. I have this code in my "PressTalk Before" section at the document level:
Code:
&State := expandstring('%{State}')
&Queue := @(10,1,3)
&PrintNum := @(10,4,4)

When I run the form through the Workflow, the global variables &Queue and &PrintNum do not have values. &State does.

I have other forms that assign values to global variables from the data file in "PressTalk Before" and they work, so I'm sure I'm doing something wrong/different this time. I just can't seem to figure out what it is...

Top
#40428 - 08/17/12 11:05 AM Re: PressTalk Before Not Working [Re: erm]
erm Offline
OL Newbie

Registered: 08/24/10
Posts: 14
I believe I have found a solution.

I created a blank first page and unchecked 'page ejects.' I added a PressTalk object to the page and put my global variable initialize code inside (and removed it from the "PressTalk Before" section).

Now my form appears to work as I expected.

Thanks!

Top