GUID

C

CW

I have a function form Patrick Helastead's book for creating a Jscript
GUID.

In the OnLoad event of the form I put the following:
*******************************************************************************
var sGUID =
XDocument.DOM.selectSingleNode("/pr:purchaseRequest/my:sGuid");

if (sGUID != null)
{
XDocument.UI.Alert("null");
XDocument.DOM.selectSingleNode("/pr:purchaseRequest/my:sGuid").text =
getJsGuid();
}
else
XDocument.UI.Alert("Already a GUID");
*******************************************************************************
What's supposed to happen is if the sGUID field was previously given a
GUID when first filling out a form then it should return (for testing
purposes) "Already a GUID" and so it won't get overwritten. Otherwise,
if it's a new form it should return the text "null" (also for testing)
meaning it needs to run the getJsGuid() function.

Problem is every form I open retuns "null" when I know it's an update.

Meaning, my Jscript is very poor. I know I have the syntax wrong. tried
if(sGuid == null) as well. Neither work for me. Should I not be using
the null method? Am I not referring to sGUID correctly?

I'd appreciate any mentoring.

TX
 
C

CW

Update. I seem to have gotten it to work the way I want using the
following code:
***********************************************************************************
var sGUID =
XDocument.DOM.selectSingleNode("/pr:purchaseRequest/my:sGuid");

if
(XDocument.DOM.selectSingleNode("/pr:purchaseRequest/my:sGuid").text ==
"")
{
XDocument.UI.Alert("null");
XDocument.DOM.selectSingleNode("/pr:purchaseRequest/my:sGuid").text =
getJsGuid();
}
else
{
XDocument.UI.Alert("Already a GUID");
}
************************************************************************************
I don't think it's a correct way of referencing an object in Jscript
(otherwise what's the var for right, but at least it works.

If anyone has any tips for cleaning this up I'm all eyes.

TX CW
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top