Question

Update custom field using event with value from another custom field

  • 15 September 2022
  • 1 reply
  • 396 views

Badge +3

Hi Community

 

I have created a Persistent custom field in the Entity Order_Quotation  → C_REPORT_CODE_QUO to enter a code which we want to use for some statistics in Aurena.

 

I have created another custom field in the entity Customer order → C_REPORT_CODE_ORD. The idea is that the ..CODE_ORD Attribute should be recived the Information from the Attribut ..CODE_QUO when the Quotationen becomes an order. 

 

i created an event which triggers the order creation to achive that but i am getting an mutating Error and the Attribut ..CODE_ORD is empty.

 

DECLARE
    info_         VARCHAR2(4000) := NULL;
    attr_         VARCHAR2(4000);
    attr_cf_    VARCHAR2(4000);

  Cursor get is 
   select objid, ifsapp.ORDER_QUOTATION_CFP.Get_Cf$_C_REPORT_CODE(CUSTOMER_ORDER_CFP.Get_objkey(QUOTATION_NO)) tmp
 from CUSTOMER_ORDER 
  WHERE QUOTATION_NO = '&NEW:QUOTATION_NO';

BEGIN
FOR rec_ in get LOOP 
     Client_SYS.Clear_Attr(attr_);
     Client_SYS.Clear_Attr(attr_cf_);
     Client_SYS.Add_To_Attr('CF$_C_REPORT_CODE', rec_.tmp, attr_cf_);  
   IFSAPP.Customer_Order_CFP.Cf_Modify__(info_, rec_.objid, attr_cf_, attr_, 'DO');  
END LOOP;

END; 

 

Can you let me know where the issue is ? 


1 reply

Userlevel 3
Badge +8

I’m assuming that the event is based on the customer_order_tab changing?  If so, at the time of processing CUSTOMER_ORDER_TAB is changing, and the IFS logic would be creating a new custom field record at the same time you’re trying to modify it.

You could try moving the event to when the CUSTOMER_ORDER_CFT has a new record - you could then do your lookup against the quotation_no on the order and get the value of your field.

Reply