Script creates error CI_Item.LCK does not have permssions

SOLVED

We sometimes ship orders by LTL carrier.  We have had issues with people signing the Bill of Lading and then finding trucking damage later.  They do not get any consideration because they signed as received in good order.  Our shipping manager wants each LTL customer to see a note on their sales order saying they need to look and claim damage before signing.  The customer service reps have had a line they are supposed to copy and paste into a /C comment line when they set up LTL.  This system has been hit or miss, so I wrote a script that should do this automatically.  My plan for the script was to change the common other ship via codes ("TRUCK" or "TRUCK SHIP") that people enter that mean LTL int "LTL".  Next, examine the lines of the sales order to see if the new MISC comment code "/LTL" or the description it creates is on the sales order (do not duplicate), and finally, if it is not an LTL shipment, to remove the LTL comment line.   

I attached this script to Post Validate on the Sales Order Header ShipVia column.  

It seems to work when I test it, but I have had 3 sales reps telling me they get an error "CI_Item.LCK does not have correct permissions".  I find only one other reference to this error in this forum and the answer was basically to do the task differently.  My script is below. 

Can anyone give me a hint on the CI_Item.LCK permission issues?

Thank you

Chris

 

'Set Variables
sShipVia = ""
sCompany = ""
bFound = 0
sSOItemComment = ""
sSOItemCode = ""

'Stop script if not OUR company

sCompany = oSession.CompanyCode

IF sCompany = "OUR" THEN

'Get the ShipVia and set it to LTL if it is TRUCK or TRUCK SHIP

retVal = oBusObj.GetValue("ShipVia$", sShipVia)
IF sShipVia = "TRUCK" THEN
	sShipVia = "LTL"
	retVal = oBusObj.SetValue("ShipVia$",sShipVia)
END IF
IF sShipVia = "TRUCK SHIP" THEN
	sShipVia = "LTL"
	retVal = oBusObj.SetValue("ShipVia$",sShipVia)
END IF
retVal = oBusObj.SetValue("UDF_SHIPVIA_COPY$", sShipVia)

'Set up to read through the lines of the sales order

Set oLines = oBusObj.AsObject(oBusObj.Lines)

'See if the LTL disclaimer is already in a comment item if we have a LTL shipment

IF sShipVia = "LTL" THEN
retVal = oLines.MoveFirst()
bFound = 0
	do WHILE oLines.EOF<>1 AND bFound<1
		retVal = oLines.GetValue("ItemCode$", sSOItemCode)
		retVal = oLines.GetValue("CommentText$",sSOItemComment)
		IF left(sSOItemComment,15) = "Any and all dam" OR sSOItemCode = "/LTL" 	THEN
			bFound = 1
		END IF
		oLines.MoveNext()
	loop
IF bFound = 0 THEN
	retVal = oLines.AddLine()
	retVal = oLines.SetValue("ItemType$","4")
	retVal = oLines.SetValue("ItemCode$","/LTL")
	retVal = oLines.Write()
END IF
END IF

'If not LTL, remove the LTL terms
IF NOT sShipVia = "LTL" THEN
retVal = oLines.MoveFirst()
bFound = 0
do WHILE oLines.EOF<>1 and bFound<1
		retVal = oLines.GetValue("ItemCode$", sSOItemCode)
		retVal = oLines.GetValue("CommentText$",sSOItemComment)
		IF left(sSOItemComment,15) = "Any and all dam" OR sSOItemCode = "/LTL" 	THEN
			bFound = 1
			retVal = oLines.Delete()
		END IF
		oLines.MoveNext()
	loop


END IF
END IF
 

Parents Reply Children
No Data