Requested Tasks

Discussions related to ReadyDoc development.
Post Reply
cklahr
Posts: 71
Joined: Tue Oct 27, 2009 3:32 am

Requested Tasks

Post by cklahr »

Attached is a document that is coded based on various Requested Tasks. I would like to add another option, that if none of these specific requested tasks exist, "NONE REQUESTED" should appear. How would I go about that?
Attachments
my_NY_ReportMunicpalDeptSearches&StreetReport.doc
(35 KiB) Downloaded 57 times
Mark McKenna

Re: Requested Tasks

Post by Mark McKenna »

You can use the <COUNT> and/or <VAR> command tokens in your document.

<COUNT>, as you might guess, counts the items in a collection - optionally using [...] style filters.
<VAR> uses local variables to store and retrieve data. You declare/assign the variable within the document, then refer to that value throughout the remainder of the document as you would a fieldcode. Currently, only scalar variables are supported, identified as such using a $ prefix to the variable name.

A few examples:

Count/display the properties in an order

Code: Select all

<COUNT {{.Property}}>
Do something if there are more than 2 properties in an order

Code: Select all

<IF ( <COUNT {{.Property}}> > 2 )>
Count the properties in an order, and store the value in a variable called propcount:

Code: Select all

<VAR $propcount ( <COUNT {{.Property}}> )>
Do something if there are more than 2 properties in an order, using the variable propcount

Code: Select all

<IF ( {{$propcount}} > 2 )>
Display the number of properties in an order, using the variable propcount

Code: Select all

Number of properties: {{$propcount}}
In your case, you might take this sort of approach:

Code: Select all

<VAR $a ( <COUNT {{.RequestedTask[{{.Task}} = "A"]}}> )>
<VAR $b ( <COUNT {{.RequestedTask[{{.Task}} = "B"]}}> )>
<VAR $c ( <COUNT {{.RequestedTask[{{.Task}} = "C"]}}> )>
...
<IF ( {{$a}} + {{$b}} + {{$c}} = 0 )>
NONE REQUESTED
</IF>
Let us know if you'd like more clarification.
cklahr
Posts: 71
Joined: Tue Oct 27, 2009 3:32 am

Re: Requested Tasks

Post by cklahr »

Thank you very much. I attached the document that I put the Variable coding into. Please let me know which part is incorrect, as it is not working properly.
Attachments
my_NY_ReportMunicpalDeptSearches&StreetReport.doc
(39 KiB) Downloaded 63 times
Mark McKenna

Re: Requested Tasks

Post by Mark McKenna »

Ah, I had a typo in my reply to you, which I've corrected. When referencing a variable, as opposed to declaring or assigning a value to it, you decorate it like a fieldcode. So it should have read:

Code: Select all

<IF ( {{$a}} + {{$b}} + {{$c}} = 0 )>
NONE REQUESTED
</IF>
Try that out and see if that takes care of your issue.

Tip - when debugging a document, it can be useful to just print the value of the variable or calculation into the document temporarily. Such as:

Code: Select all

{{$a}}
or

Code: Select all

<CALC ( {{$a}}  + {{$b}} + {{$c}} )>
This sort of thing can help when trying to understand why the execution path of a document took a certain path (e.g. why an IF evaluated as true, etc.).
cklahr
Posts: 71
Joined: Tue Oct 27, 2009 3:32 am

Re: Requested Tasks

Post by cklahr »

Thank you very much. That worked!! :)
cklahr
Posts: 71
Joined: Tue Oct 27, 2009 3:32 am

Re: Requested Tasks

Post by cklahr »

Another thing, right now it's coded like this:

<VAR $a ( <COUNT {{.RequestedTask[{{.Task}} = "Certificate of Occupancy Search"]}}> )>
<VAR $b ( <COUNT {{.RequestedTask[{{.Task}} = "Department of Buildings Search"]}}> )>
<VAR $c ( <COUNT {{.RequestedTask[{{.Task}} = "Department of Fire Search"]}}> )>
<VAR $d ( <COUNT {{.RequestedTask[{{.Task}} = "Emergency Repair Lien Search"]}}> )>
<VAR $e ( <COUNT {{.RequestedTask[{{.Task}} = "Street Report"]}}> )>
<VAR $f ( <COUNT {{.RequestedTask[{{.Task}} = "Department of Air Resources Search"]}}> )>
<VAR $g ( <COUNT {{.RequestedTask[{{.Task}} = "Oil Burner Permit Search"]}}> )>
<VAR $h ( <COUNT {{.RequestedTask[{{.Task}} = "Highway Department Search"]}}> )>
<VAR $i ( <COUNT {{.RequestedTask[{{.Task}} = "Department of Health Search"]}}> )>
<VAR $j ( <COUNT {{.RequestedTask[{{.Task}} = "Landmark Search"]}}> )>
<IF ( {{$a}} + {{$b}} + {{$c}} + {{$d}} + {{$e}} + {{$f}} + {{$g}} + {{$h}} + {{$i}} + {{$j}} = 0 )>

NONE REQUESTED
</IF>


However, now I need to change that. I need it to pull "NONE REQUESTED" either if the task doesn't exist at all or if the task exists, but the status is Required. How would I do that?
Mark McKenna

Re: Requested Tasks

Post by Mark McKenna »

Effectively, you want to know if there are any tasks of the targeted task types where the status is not required. If there are, then you don't want to display your custom message.

Code: Select all

<VAR $a ( <COUNT {{.RequestedTask[{{.Task}} = "Certificate of Occupancy Search" and {{.Status}} <> "Required"}}]> )>
<VAR $b ( <COUNT {{.RequestedTask[{{.Task}} = "Department of Buildings Search" and {{.Status}} <> "Required"}}]> )>
...
<IF ( {{$a}} + {{$b}} + {{$c}} + {{$d}} + {{$e}} + {{$f}} + {{$g}} + {{$h}} + {{$i}} + {{$j}} = 0 )>
NONE REQUESTED
</IF>
Each variable will be set to 0 if (a) there are no tasks of the targeted task type, or (b) there are tasks of the targeted task type but they all have a status of Required.
cklahr
Posts: 71
Joined: Tue Oct 27, 2009 3:32 am

Re: Requested Tasks

Post by cklahr »

Thank you very much!! :)
Post Reply