Quantcast
Channel: Sage 100
Viewing all articles
Browse latest Browse all 36990

Forum Post: Having trouble with a script

$
0
0
We have many items in our system that need to have their alternate items updated.  As far as I can tell, if we try to just import 'over' the existing alternates, we get errors saying the alternate/priority already exists, so it looks like we need to delete them.  The problem is, there are THOUSANDS of them.  So I attached the below script to a button in item maintenance (just so I could use the existing Session object and not have to create a ProvideX.script object), but I'm not getting the expected results.  (For all of the items that need to have their existing alternates deleted, I flagged them by setting their InventoryCycle = 'X'. SET oAlternate = oSession.AsObject(oSession.GetObject("IM_AlternateItem_bus")) SET oItem = oSession.AsObject(oSession.GetObject("CI_ItemCode_svc")) ic = "" ac = "" t = "" vend = "" count = 0 count2 = 0 retVal = oItem.MoveFirst() while not cbool(oItem.EOF) retVal = oItem.GetValue("ItemCode$", ic) retVal = oItem.GetValue("InventoryCycle$", t) if t = "X" then retVal = oAlternate.SetBrowseFilter(ic) retVal = oAlternate.MoveFirst() while not cbool(oAlternate.EOF) retVal = oAlternate.Delete() if retVal 1 then retVal = oSession.AsObject(oSession.UI).MessageBox("Error deleting " + ic + "/" + ac + ": " + CSTR(oAlternate.LastErrorMsg)) else count = count + 1 end if retVal = oAlternate.MoveNext() wend end if retVal = oItem.MoveNext() wend It seems like the above is only deleting one of the alternates for each of the items marked with an InventoryCycle of 'X'. Anyone see anything wrong with this? I'd appreciate any input!    

Viewing all articles
Browse latest Browse all 36990

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>