- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Error after using bSave in a VBScript
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
09-16-2011 01:33 PM
Our client has a validation script that runs on Save of a Sales Order. It checks all the lines on the order, and looks for 2 required items (ORD & FREI). If those items aren't there, we change bSave to false and use a MsgBox to remind the user to enter the required lines.
The script works fine the first time it fires. If the user then adds both line items on the order, then saves, everything is fine. However, if the user enters only adds one of the required lines, then saves the sales order, the script fires again, reminding them that they need both items.
However, this time after the user adds the second required item, when the sales order is saved, the MAS error pops up "Enter Sales Orders and Quotes already exists. Save canceled."
I was so proud of this script until this came up! It would really solve a big issue at the client. Has anyone experienced this, and if so, is it resolvable? (I tried running a trace on the database, and I can't figure out what's causing it to fail.)
Here is my script, in case it's an error within it:
If Form.Controls("txtSONum") <> "" and (Form.Controls("lkuSource").Text = "FULFILLMENT" or Form.Controls("lkuSource").Text = "WEB" or Form.Controls("lkuSource").Text = "PRODUCTION" or Form.Controls("lkuSource").Text = "PROTOTYPE") Then
Dim ItemID, r, m, frt, op
frt = 0
op = 0
Form.Controls("grdDetail").col = 1
If Form.Controls("grdDetail").DataRowCnt > 0 Then
m = Form.Controls("grdDetail").DataRowCnt
For r = 1 to m
Form.Controls("grdDetail").row = r
ItemID = Form.Controls("grdDetail").value
'MsgBox ItemID
If Left(ItemID,4) = "FREI" Then
frt = 1
end if
If Left(ItemID,3) = "ORD" Then
op = 1
End If
If Frt = 1 and op = 1 Then
Exit For
End If
Next
End if
If frt = 0 or op = 0 Then
MsgBox "Both Freight and Order Processing line items are required for this order."
bSave = False
End if
End if
Hollie
Re: Error after using bSave in a VBScript
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
09-16-2011 02:10 PM - last edited on 09-16-2011 02:13 PM
Try moving your validation outside the DM event. Look for other field level validation and add your code there.
** Just realized your code is in VBScript. Not actually in the source code. Sorry. **
Sage 500 Engineering
Re: Error after using bSave in a VBScript
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
09-16-2011 03:02 PM
Yep, we're trying to stay in the Customizer framework, so we're using VBScript on the events available to Customizer, which are sadly lacking...
Thx, Hollie
Hollie
Re: Error after using bSave in a VBScript
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
09-16-2011 03:52 PM
Are you doing this in MAS 500 or MAS 90 as I see you are registered as a MAS 90 Customer.
e2b teknologies, inc
www.e2btek.com
Re: Error after using bSave in a VBScript
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
09-19-2011 09:38 AM
I am both a MAS 90 and MAS 500 consultant, I don't know why it says I'm a customer.
This is for a MAS 500 customer. I don't think those control references would work in MAS 90. ![]()
Thx, Hollie
Hollie
Re: Error after using bSave in a VBScript
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
09-19-2011 09:42 AM
There is an effort in 7.50 to improve the features of customizer. I'll make sure to bring up this topic during our discussions.
Sage 500 Engineering
Re: Error after using bSave in a VBScript
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
09-20-2011 08:15 AM
I've seen the message you described even doing modifications using VB 6. It indicates that your script is always trying to create new records instead of updating the existing ones. Working with the grids on a MAS 500 form is difficult at best using Customizer especially when talking about the Sales Order Entry screen. Customizer really was not designed to manipulate data in the grids though as you can see you do have access to the control.
Most likely what is happening is the underlying code for the task isn't recognizing that an update needs to occur and tries to create the record(s) again. You may have to rethink how you need to accomplish what you want to do either by redesigning your Customizer routine to manually update the records after the task does it save, or modify the task using VB 6 and the Enter Sales Order Entry source code to add your routine to the task itself so it properly saves the data you need.
e2b teknologies, inc
www.e2btek.com
Re: Error after using bSave in a VBScript
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
09-20-2011 11:45 AM
You could write a trigger (maybe). Should work though and doesn't require a custom mod. I'm not sure if I'm thinking it all the way through though...
Re: Error after using bSave in a VBScript
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
09-21-2011 07:08 AM
Thanks for your replies. Unfortunately, Louis, neither of those options works for their scenario. The user has to choose an item to be added, so I can't add the record for them, since there are several options, but at least one of those options must be included by the user. In addition, the client does not want to modify source code. So it's back to the drawing board! The weird thing is that it seems to happen only if the user gets the error twice; if they add all the required items after the first error, there's no problem. But if they only enter one required item and not the second, the script fires and then they can't save the SO.
I'm going to run this with SQL profiler on and see what's happening in the background, I haven't tried that yet.
Hollie
Hollie
Re: Error after using bSave in a VBScript
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
09-21-2011 07:11 AM
A trigger, hmmm. I'll have to think about that one. If I use a trigger to validate the lines, I'll still have to capture it in the VB and stop the save, won't I? or maybe the trigger would catch it before the save, where it doesn't seem to be doing that now. I'll look into that one.
Hollie
Hollie


