The CreatorCon Call for Content is officially open! Get started here.

Expense Lines - Is there a way to know who processed the expense?

Onoderav
Tera Contributor

Hi, guys!
Concerning expense lines, client requested a field in the fm_expense_line list that shows the user who processed the expensive. I haven't found anything that shows this kind of information. Someone knows if there's a way to achieve this?
Thanks in advance.

1 ACCEPTED SOLUTION

Iraj Shaikh
Mega Sage

Hi @Onoderav 

Please follow the steps below to accomplish your requirement

1. Create new field on fm_expense_line table and reference it to the "User [sys_user]" table.

IrajShaikh_0-1705133656068.png

 

2. Create a new business rule that triggers "before" an insert or update on the fm_expense_line table.

Filter condition: State changes to Processed

Srcipt:

 

(function executeRule(current, previous /*null when async*/ ) {

    current.u_processed_by = gs.getUserID();

})(current, previous);

 

 

 

Screenshot 2024-01-13 at 1.48.43 PM.png

Screenshot 2024-01-13 at 1.52.15 PM.png

 

Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

2 REPLIES 2

Iraj Shaikh
Mega Sage

Hi @Onoderav 

Please follow the steps below to accomplish your requirement

1. Create new field on fm_expense_line table and reference it to the "User [sys_user]" table.

IrajShaikh_0-1705133656068.png

 

2. Create a new business rule that triggers "before" an insert or update on the fm_expense_line table.

Filter condition: State changes to Processed

Srcipt:

 

(function executeRule(current, previous /*null when async*/ ) {

    current.u_processed_by = gs.getUserID();

})(current, previous);

 

 

 

Screenshot 2024-01-13 at 1.48.43 PM.png

Screenshot 2024-01-13 at 1.52.15 PM.png

 

Please mark this response as correct or helpful if it assisted you with your question.

sumanta pal
Kilo Guru


Sure, you can achieve this by creating a new field in the 'fm_expense_line' table to store the information of the user who processed the expense. You can then update this field whenever an expense is processed. Here are the steps:

1. Navigate to the 'fm_expense_line' table by typing 'fm_expense_line.list' in the left navigation filter.
2. Click on 'Configure' -> 'Table' to open the table schema.
3. Click on 'New' to create a new field.
4. Set the 'Type' to 'Reference', 'Label' to 'Processed By', and 'Reference' to 'User [sys_user]'.
5. Click on 'Submit' to create the field.

Now, you need to update this field whenever an expense is processed. You can do this by creating a Business Rule:

1. Navigate to 'System Definition' -> 'Business Rules'.
2. Click on 'New' to create a new Business Rule.
3. Set the 'Name' to 'Update Processed By', 'Table' to 'Expense Line [fm_expense_line]', and 'When' to 'before'.
4. Set the 'Insert' and 'Update' checkboxes to true.
5. In the 'Advanced' tab, write the following script:

javascript
(function executeRule(current, previous /*null when async*/) {
// Set the 'processed_by' field to the current user
current.processed_by = gs.getUserID();
})(current, previous);


6. Click on 'Submit' to create the Business Rule.

Now, whenever an expense is processed, the 'Processed By' field in the 'fm_expense_line' list will show the user who processed the expense.


nowKB.com