FETCH command on a MC phrase

Discuss your general Proclaim related queries here.
Post Reply
jwhelan
Posts: 6
Joined: Fri Jan 30, 2015 11:18 am
Been thanked: 2 times

FETCH command on a MC phrase

Post by jwhelan » Fri Jan 30, 2015 11:31 am

Hi

Anyone have any ideas on the best way to work around a problem I have come across. Basically, I need to be able to extract the content of MC or TC phrases so that I can export the details over to a referrers website. My initial idea was to create a maths item that is placed in the AFTER maths of every MC or TC that would run a fetch and obtain the History Details of the last MC or TC (depending which the user has performed).

However, what I have found is that the after maths does not run after the history line has been created so what is returned is not the last but the penultimate.

We want to be able to use this functionality across multiple action types (ie SL, SE, MC, TC etc etc) so what I thought would be an elegant solution (using LAST-ACTION to work out what action and corresp it is and then building the fetch from there) will not work. Here is the code that I started to build;

Code: Select all

last = LAST-ACTION 
v-act = LISTITEM( last , 2 , "$" ) 
result = FETCH( "CONTENT" , "History" , "details" , "FOR LAST History NO-LOCK WHERE History.case_no = '" + {case.key} + "' AND (action_type = 'v-act' )" ) 
MESSAGE( result )
A solution would be to create a screen within a case to replace the MC / TC feature but this is not an option due to the added admin overhead each time a new phrase is created plus it would take a silly amount of time to set up initially.

Does anyone have any suggestions / solutions?

steve
Posts: 399
Joined: Wed Nov 30, 2011 10:20 pm
Been thanked: 85 times

Re: FETCH command on a MC phrase

Post by steve » Fri Jan 30, 2015 12:12 pm

Hi,
FETCH, as you have found, won't work here, as the history table entry hasn't been committed until after the entire AFTER maths of the MC/TC phrase is completed.
We resorted to using the MIWH to get details of MC/TC (you can have the MIWH replicate history details). You can create an extra column in the MIWH MSSQL database as a 'processed' flag for your third party application to pull out only new TC/MC entries. The downside is the lag when writing to the MIWH.
Last edited by steve on Fri Jan 30, 2015 12:33 pm, edited 1 time in total.

jwhelan
Posts: 6
Joined: Fri Jan 30, 2015 11:18 am
Been thanked: 2 times

Re: FETCH command on a MC phrase

Post by jwhelan » Fri Jan 30, 2015 12:29 pm

Hi Steve

The LAST-ACTION does work correctly and it does return the details of the MC that the user is attempting to post. You can use LAST-ACTION in after maths on letters when using a master document to do clever things so something is being written to the database before the after maths starts.

This is what is really frustrating as I would have thought the LAST-ACTION would work in a similar way to the FETCH. I can't see how one would work but the other wouldn't.

As for using the MIWH, it wouldn't work for what we need it to do as it needs to be real time and there are other considerations that form part of the XML that we export.

steve
Posts: 399
Joined: Wed Nov 30, 2011 10:20 pm
Been thanked: 85 times

Re: FETCH command on a MC phrase

Post by steve » Fri Jan 30, 2015 12:33 pm

sorry, yes got my terms mixed up, original reply will be edited.

FETCH fails as the history hasn't been committed, not LAST ACTION. LAST-ACTION is a Main Case Handling user interface thing, not a history tool:

LAST-ACTION will also only work for interactions in Main Case Handling, not any correspondence created via maths/auto-routines. This gives you an idea as to why LAST-ACTION would work in the AFTER maths on the item just created, and not FETCH.
The comment from Eclipse devs on this one is:

"
I didn’t expect this to work (and I tried several things as you have, just in case). The reason I didn’t expect it to work, is the Send Letter function.

It is possible, on a dictacted letter, to use the update after to effectively prevent the letter being pushed into case history (I think you have result = “no” as the output for that). It returns the user to the send letter action box, although at this point they can effectively change to a different correspondent/letter so it’s not widely used.

Therefore, if it’s possible to interrupt the passage of a letter using the update after, it follows logically that the letter cannot have yet been committed to the case history yet. Therefore this explains why the update after, even when using the fetch commands, can only find the previous history entry.

"

SteveH
Posts: 77
Joined: Thu May 02, 2013 2:54 pm
Has thanked: 4 times
Been thanked: 2 times

Re: FETCH command on a MC phrase

Post by SteveH » Fri Jan 30, 2015 4:19 pm

Hey jwhelan

You said in your original post that you want to export the content that is typed in the action window. Were you planning on placing the variable that the FETCH command is run from into an alpha field then exporting to CSV/XML?

In which case, why not place the LAST-ACTION & FETCH syntax you are devising into a maths field and run it on case exit in a linked action - or dump the code directly in the linked action that is run on case exit?
Saves any screens having to be built.

The only issue you will have with this solution is that every time someone exits the case, the syntax will run, so you'll need to build something into your procedure which makes it run the once for that item.

Below is an example you can use where I email our Costs department a notification when a Fee Earner actions any post, when the file has been assigned to costs. The procedure runs when a Fee Earner exits the case. Put simply - it scans the history for the last IM, IE or IF and then emails the costs department. I use date checks to stop it running every time someone exits the case. The result is one email is sent to the costs handler when a new IM, IE or IF is in the history that has been actioned.

Code: Select all

# ========================= 
# Costs Post In Check when exiting 
# the case. If email already sent, 
# ignore email send. 
# ========================= 
# 
# Todays Date 
v-Today = TODAY 
# 
# Last History Date for imported file 
v-IMDate = FETCH( "TOTAL" , "History" , "created_date" , "FOR LAST History NO-LOCK WHERE History.case_no = '" + {case.key} + "' AND (action_type = 'IM' OR action_type = 'IE' OR action_type = 'IF' )" ) 
# 
# Last History Date - breakdown and rebuild 
# The year shows 2 digits instead of 4 otherwise - when it comes to the date comparison 
v-Day = DAY( v-IMDate ) 
v-Month = MONTH( v-IMDate ) 
v-Year = YEAR( v-IMDate ) 
v-IMDate = DATE( v-day , v-month , v-year ) 
# 
# Make sure that the dates can be compared against each other 
v-Today = TEXT( v-Today ) 
v-IMDate = TEXT( v-IMDate ) 
# 
# Check to see if an email needs sending to costs 
IF v-IMDate = v-Today THEN 
	IF {Costs Dept last emailed about incoming mail.Date} = v-IMDate THEN 
		# Email already sent  
	ELSE 
		# Email needs sending 
		v-run = {Costs Post In.Text} 
		UPDATE( {case.key} , "" ) 
	END  
ELSE 
	# No imported document found with todays date 
END  
There's probably a better way of doing it, but it works and serves its purpose.

SteveH

Carl
Posts: 1
Joined: Tue Aug 27, 2019 2:27 pm

Re: FETCH command on a MC phrase

Post by Carl » Tue Aug 27, 2019 2:35 pm

Hi

Has this one moved on any in the past 4-5 years since the last update? I'm attempting to get the History details, Corr Type etc of the document in the "After" Maths but have come across the issue that the doc has not been committed to the history until the "After" maths has totally finished and therefore will only return the previous documents details!

I'm working on an "On the Fly" Encryption process that takes a Word document template, exports it to PDF, Encrpyts it and drops it back onto the history. The only thing thats letting it down is the fact I can't get it to pull the History Details, Corr Type, Units, Category etc from the original word and drop onto the PDF when I import the file back in.

Any further thoughts on this one.

Thanks

Carl

ethusiastp
Posts: 24
Joined: Tue Dec 05, 2017 12:33 pm
Been thanked: 1 time

Re: FETCH command on a MC phrase

Post by ethusiastp » Tue Aug 27, 2019 3:02 pm

Carl wrote:
Tue Aug 27, 2019 2:35 pm
Hi

Has this one moved on any in the past 4-5 years since the last update? I'm attempting to get the History details, Corr Type etc of the document in the "After" Maths but have come across the issue that the doc has not been committed to the history until the "After" maths has totally finished and therefore will only return the previous documents details!

I'm working on an "On the Fly" Encryption process that takes a Word document template, exports it to PDF, Encrpyts it and drops it back onto the history. The only thing thats letting it down is the fact I can't get it to pull the History Details, Corr Type, Units, Category etc from the original word and drop onto the PDF when I import the file back in.

Any further thoughts on this one.

Thanks

Carl
I wrote a solution at one of my old jobs where the data would export either on the next action, or case exit maths.

So if you were exporting calls, you would do a count and then export on the next make or take call, or case exit maths.

Either way you'd always be one behind

ISimpson
Posts: 10
Joined: Mon Mar 18, 2019 5:14 pm
Been thanked: 2 times

Re: FETCH command on a MC phrase

Post by ISimpson » Fri Aug 30, 2019 8:37 am

Does the transfer of data need to be done at the exact time of the MC?

One solution could be to create an Auto-Routine which runs in the background every [x]minutes to extract the data (meaning the routine is always looking at the last committed history data) and send it where you want it to be sent. Write the maths to work out what needs to be sent (including tests on time based previous submissions) coupled with an SQL statement to select the case group to perform the maths on. I've found that using Auto Routines in place of in-case maths at times is substantially quicker.

Post Reply