Database Error: Cannot set 'value' as 'undefined' (SourceFile#107)
I am running two queries for my form. The first is a drop down list that is being populated with Vendor Names. The second rule fires off on the selection of the drop down list and populates 3 fields; Phone, Fax, and Email. I have tried everything I can think of to get this to work with the customer's new accounting database, but no matter what I do I can only retrieve the Phone and Fax. It errors on the email every time with the following error:
20:36:04,093 WARN RuleObserver:458 - Error evaluating rule [Purchase Request v2.0.Purchasing Vendor Names Return]: Cannot set 'value' as 'undefined' (SourceFile#107)
Here are my config file entries:
<query name="allVendors">
<retrieve>
<statement> select VendName, ContactEMailAddr, ContactPhone, ContactFax FROM vdvVendorAddr2 order by VendName</statement>
</retrieve>
</query>
<query name="vendorInfo">
<retrieve>
<statement> select VendName, ContactEMailAddr, ContactPhone, ContactFax FROM vdvVendorAddr2 WHERE VendName ='{reqVendor}'</statement>
</retrieve>
</query>
Here is the business rule for the second query:
//Purchasing Vendor Information
if (reqVendor.value.length >0) {
vendorEmail.value = 'NA';
vendorPhone = 'NA';
vendorFax = 'NA';
eval ('x=' + http.get('http://localhost:8082/database/mas500vendor/vendorInfo?reqVendor=' + reqVendor.value));
vendorFax.value = x.resultSet[0].ContactFax;
vendorPhone.value = x.resultSet[0].ContactPhone;
vendorEmail.value = x.resultSet[0].contactemailaddr;
}
When I run this query in the address bar, I get a good return.
Here is the query address:
http://localhost:8082/database/mas500vendor/vendorInfo?reqVendor=Top Hat Productions
Here is the return: (of course I modified the return info for this post to not be real information)
<?xml version="1.0" encoding="UTF-8"?>
-<vendorInfo xmlns="http://www.frevvo.com/database/vendorInfo">
-<row xmlns=""> <VendName>Top Hat Productions</VendName>
<ContactEMailAddr>email@tophat.com</ContactEMailAddr>
<ContactPhone>714xxxxxxx </ContactPhone>
<ContactFax>714xxxxxxx </ContactFax>
</row>
</vendorInfo>
-
This error usually indicates that the value that you are trying to assign, viz. the email address is actually not present in the database. Maybe in some of your database records the email address column is blank, so the business rule is trying to assign values when there are no values in the result set and failing there.
You can avoid this error by checking if the value that you are trying to assign really exists. For e.g you can change your assignment statement like this:
if(x.resultSet[0].contactemailaddr) vendorEmail.value = x.resultSet[0].contactemailaddr; else vendorEmail.value = null;
0
Please sign in to leave a comment.
Comments
1 comment