Skip to main content

Hello , 

I need to prevent the creation of a new customer invoice if the customer is not approved .

I tried to create a custom event to control that , But it does’t stop  the creation of a new customer invoice .

I applied the custom event on CustomerOrderInvHead (LU) and INVOICE_TAB and here is the script of my event action : 

DECLARE 
lu_name_ VARCHAR2(1000) ; 
key_ref_  VARCHAR2(32000) ; 
result_ VARCHAR2(32000) ; 
--approval_status_ VARCHAR2(1000) ; 
BEGIN
lu_name_     := 'CustomerOrderInvHead'; 
key_ref_   := 'CUSTOMER_ID=&NEW:IDENTITY^'  ;                     
result_ := approval_routing_api.is_approved(lu_name_,key_ref_);    

IF (result_ = 'FALSE') THEN
      Error_SYS.Record_General(lu_name_, 'APPROVAL_ROUTING: This invoice cannot be created. The customer is not approved') ;
end if;

END;

 

Does anyone have an idea what could be the problem ? 

 

Thank you ,

Hanane

 

 

@Hanane 

My starting point would be check the value result_ . Can you try out the following. 

This will print out the result_ value so we can see what the approval api returning

Error_SYS.Record_General(lu_name_, 'APPROVAL_ROUTING: This invoice cannot be created. The customer is not approved') ;

 


Thank you for the reply .

Actually the problem was : when the field invoice cust in the customer is filled , the check is directed to the invoice customer instead of the ordering customer .

It’s okey for my case so problem resolved , but I’ll leave my explanation here in case it will help someone else .


Reply