Static Dispatch Variable

How do you keep a dispatch variable constant?

When you have a variable defined in dispatch it always seem to change as you work through "For All documents"

For example: 

I have an ECN file that has the name "ECN-0120.DOC" in that file is a custom property "ECN-Number" it is = "ECN-0120".

I have several drawings pasted as reference to this ECN file and as I submit the ECN for approval, the pasted references, in this case drawings and the associated parts go into pending approval.  This is all GOOD.

I have a dispatch program that will cycle through the files, find the ECN File and Corresponding custom property of "ECN-0120"

I then want to recycle through the documents and assign the ECN-0120 to the SLDDRW files.  Each ECN may have 1 or More drawings/parts associated with it

However every time through it resets the "ECN-Number" to nothing once it grab the any file other than ECN-0120.DOC.

I want to automatically assign the ECN-Number to the drawings/parts automatically so I don't have clarical error.  I hope to get this working so the Revision Block updates as well.

Am I missing something?

SolidworksSolidworks Pdm enterprise Pdm