Hello to all!
i have made a validation for the users in order to fill in Goods Receiipt PO a field called Location.
the function creatred is as follows
IF @object_type = N'20' AND (@transaction_type = N'A' OR @transaction_type = N'U') --OR @transaction_type = N'U')
SELECT @LOC4=U_Location FROM PDN1 WHERE DOCENTRY=@LIST_OF_COLS_VAL_TAB_DEL
SELECT @LOC41=U_BarCode from [@CHM_WHS1]
select @BASEREF=BASEREF FROM PDN1 WHERE DOCENTRY=@LIST_OF_COLS_VAL_TAB_DEL
IF (select @LOC4) IS NULL
SET @error_message=N'Please Fill The Location Field'
If (select @LOC4) not in ( select U_BarCode from [@CHM_WHS1])
SET @error_message= N'The Location '+@LOC4+N' is wrong '
if the user does not fill the field location the message 'Please Fill The Location Field' is displayed
if the user types a location that does not exist in a table then the message is the 'The Location '+@LOC4+N' is wrong '
the actual problem now is while a user makes a new Goods Receipt PO by using the Copy from an existing document such as a Purchase Order.
if it is considered that in the Purchase order, the field is filled with a wrong location, then in Goods Receipt my function does not validate this field.
i made some tests such as
i created a PO with a wrong Location
i saved it
i made a new Goods Receipt by using a copy from the one i created before
if i leave the document as is and there are some lines with not Location filled, then the validation will take place only for the lines that are empty and not for the values transfered from the PO
it is quite strange because i would like to lock the PO as well but it is not possible to fill the Location filled during this action because it is impossible to know where to keep these items while the Goods Receipt takes place so this field must remain empty