I have created a Persistent custom field in Sales Basic Data → Salesman to enter Sales manager of each salesman.
I have created another custom field in Customer order → Misc Order info tab and I want to update Sales manager’s id into that custom field using an event.
i created an event to achive that but i am getting no result. Customer order doesn’t fire any error too.
SELECT CF$_SALES_MANAGER INTO SalesM_ from SALES_PART_SALESMAN_CFV WHERE salesman_code = '&NEW:SALESMAN_CODE';
IF CUSTOMER_ORDER_API.Get_Authorize_Code('&NEW :ORDER_NO') = 'IWT' THEN UPDATE Customer_Order_Cft SET CF$_S_MANAGER = SalesM_ WHERE rowkey = (SELECT rowkey FROM Customer_Order_tab WHERE order_no = '&NEW:ORDER_NO'); END IF;
END;
Page 1 / 1
you have a space between NEW and :ORDER_NO
If still an issue - we would need to know whether it is a reference-type field or just a text field.
That affects whether you need to use CF$_SALES_MANAGER or CF$_SALES_MANAGER_DB
If still an issue - we would need to know whether it is a reference-type field or just a text field.
That affects whether you need to use CF$_SALES_MANAGER or CF$_SALES_MANAGER_DB
Hi Paul, Thanks for commenting,
I removed the space but still the same issue. Both custom fields are text fields.
ok, you will need to take it apart to see where the problem is...
If the select statement was not finding any data, you would be seeing a “no data found” error there. Aside: I would recommend using an explicit cursor here instead- the “no data found” error is not good for users to see.
Next i would remove the IF condition and see if it then works; that would imply that the IF condition is not being met.
Finally, you need to confirm whether the event action as a whole is running. My recommendation would be to drop this line into the script and see if the error appears at that point -if the error shows up, it means the event action ran and reached that point.
Error_SYS.Record_General('PurchasePart','You are here');
(If you don’t see the error, this tells you the event/action is not being triggered).
I agree with Paul - make sure the custom event is firing. If it is, I wonder if you can directly run an update statement to a DB table from inside a custom event.
If that’s the problem, you need to use the standard modify statement. Something like
ok, you will need to take it apart to see where the problem is...
If the select statement was not finding any data, you would be seeing a “no data found” error there. Aside: I would recommend using an explicit cursor here instead- the “no data found” error is not good for users to see.
Next i would remove the IF condition and see if it then works; that would imply that the IF condition is not being met.
Finally, you need to confirm whether the event action as a whole is running. My recommendation would be to drop this line into the script and see if the error appears at that point -if the error shows up, it means the event action ran and reached that point.
Error_SYS.Record_General('PurchasePart','You are here');
(If you don’t see the error, this tells you the event/action is not being triggered).
Hi Paul,
Excellent guidance, Now i know my event is firing when i release the order. But yet I am unable to update the field and I am getting below error
I agree with Paul - make sure the custom event is firing. If it is, I wonder if you can directly run an update statement to a DB table from inside a custom event.
If that’s the problem, you need to use the standard modify statement. Something like
As i replied to paul Event is firing. but unable to update the field.
yeah, that autonomous transaction thing is maybe not supported in IFS Events. I have not used it.
I suspect the next issue you might hit will be “table is mutating, trigger may not see it”.
@Tj12 - I think your cursor statement might be the problem.
Cursor getobj is select objid from CUSTOMER_ORDER WHERE salesman_code = '&NEW:SALESMAN_CODE';
Is retrieving all customer order rows with the salesman code. You need the 1 record that matches your order. But, I think &NEW:ROWKEY on customer_order_tab is the Object ID in customer_order (you’d have to look at the view definition to confirm - or just try it).
@Tj12
There are challenges in the way you are achieving this. But I am struggling to understand why you are doing it. Is it because you want to store info on the current sales manager when the order was released?
Could you not just add a reference field to display the sales manager on the customer order instead of setting it in a persistent field?
@Tj12
There are challenges in the way you are achieving this. But I am struggling to understand why you are doing it. Is it because you want to store info on the current sales manager when the order was released?
Hi Hans
Yes and Business want to populate manager automatically. They are too lazy to select and enter it.
Could you not just add a reference field to display the sales manager on the customer order instead of setting it in a persistent field?
Hi Anmise
Can. but business want to fill the manager automatically when they save the order or release the order
The relationship between sales manager and salesman is normally in the organisation diagram (who does the salesman refer to). When you make the sales manager cf in sales basic data, you make data where it does not belong. It could/will be in conflict with the definition of your organisation.
Can you not lookup the sales manager in the organisation diagram?
@Tj12
There are challenges in the way you are achieving this. But I am struggling to understand why you are doing it. Is it because you want to store info on the current sales manager when the order was released?
Hi Hans
Yes. Business want save this data and populate these into reports. If i use reference fields I assume that i won’t be able to see history data if manager got changed
Maybe you could trigger it on the CustomerOrderHistory instead. Below code works, but you’d obviously have to add/tweak some conditions either in the event action
Cursor get is select objid, ifsapp.SALES_PART_SALESMAN_CFP.Get_Cf$_Sales_Manager(SALES_PART_SALESMAN_CFP.Get_Objkey(salesman_code)) salesmanager from CUSTOMER_ORDER WHERE order_no= '&NEW:ORDER_NO';
BEGIN IF '&NEW:HIST_STATE' = 'Released' AND '&NEW:MESSAGE_TEXT' = 'Released' THEN
FOR rec_ in get LOOP
Client_SYS.Clear_Attr(attr_); Client_SYS.Clear_Attr(attr_cf_); Client_SYS.Add_To_Attr('CF$_SALES_MANAGER', rec_.salesmanager, attr_cf_); IFSAPP.Customer_Order_Cfp.Cf_Modify__(info_, rec_.objid, attr_cf_, attr_, 'DO'); END LOOP; END IF;
END;
Hi Guys
Finally was able to figure it out after doing some tweaks in the code.
However it still give active autonomous transaction detected error but after putting COMMIT command into the event action, I didn’t get any errors
Any Advice ?
Hi Guys
Finally was able to figure it out after doing some tweaks in the code.
However it still give active autonomous transaction detected error but after putting COMMIT command into the event action, I didn’t get any errors
Any Advice ?
Did you try the previously suggested trigger on the history table?
Hi Guys
Finally was able to figure it out after doing some tweaks in the code.
However it still give active autonomous transaction detected error but after putting COMMIT command into the event action, I didn’t get any errors
Any Advice ?
Did you try the previously suggested trigger on the history table?
Hi Anmise
Just tried with your suggestion and it works perfectly without mutating error. This will work for me definitely.