- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Prevent New Standard Items From Being Created
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-11-2012 06:56 AM
I’m trying to come up with a way to prevent standard inventory items from being created based on certain criteria regarding the ItemCode$. For instance I may not want the users to be allowed to enter an item that begins with a space. The ItemCode$ field is not available in the validation logic for scripting, so I was looking at the Post-Read Table. I notice in SY_Maint there is this cSetToReadOnlyReason$. Would the following Post-Read script for CI_Item be the best way to handle this? Does anyone see any issues with this approach?
CI_Item_ItemCode = ""
retVal = 0
If (oBusObj.EditState = 2) Then
retVal = oBusObj.GetValue("ItemCode$", CI_Item_ItemCode)
If (Left(CI_Item_ItemCode, 1) = " ") Then
oBusObj.SetToReadOnly("Item Code cannot begin with a space.")
End If
End If
Re: Prevent New Standard Items From Being Created
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-11-2012 09:46 AM
I haven't used SetToReadOnly, but if that's working for you, the code looks fine.
To check the ItemCode, consider using the Trim function instead of Left. This would catch codes beginning or ending with a space.
...
If (Trim(CI_Item_ItemCode) <> CI_Item_ItemCode) Then
...
Kencove Farm Fence
Re: Prevent New Standard Items From Being Created
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-12-2012 06:51 AM
Thanks for the suggestion. I have settled on the following bit of code that seems to work:
CI_Item_ItemCode = ""
retVal = 0
If (oBusObj.EditState = 2) Then
retVal = oBusObj.GetValue("ItemCode$", CI_Item_ItemCode)
If (Trim(CI_Item_ItemCode) <> CI_Item_ItemCode) Then
If CBool(oScript.UIObj) Then
retVal = oSession.AsObject(oSession.UI).MessageBox("Invalid Item Code", "Item Code cannot begin with a space.")
retVal = oScript.InvokeButton("BT_CANCEL")
Else
oBusObj.SetToReadOnly("Item Code cannot begin with a space.")
End If
End If
End If


