Need to auto populate assignment group in Transfer order line Task Form

bhargavi143
Tera Contributor

Hi,
I need to add  assignment group field in Transfer order line task form and i need to auto populate that assignment group value with the transfer order form of "To stockroom " assignment group value.
Please help me .

 

bhargavi143_1-1699277944241.png

 

 

1 ACCEPTED SOLUTION

Hi @bhargavi143 

You can put a Try Catch in the function to see whether it's able to catch the error or not. Use gs.info() to log the system log.

Something like this.

findAndCreateTask: function(modelCategorySysId, stage) {
    try {
        var transferOrderLine = current.sys_id;
        var transferOrder = current.transfer_order;
        var modelCategoryGR = this.findModelCategory(modelCategorySysId, stage);

        // Create task for the found model category
        if (!gs.nil(modelCategoryGR.getUniqueValue())){
            this.createTask(modelCategoryGR, transferOrderLine, transferOrder);
        }
    } catch (e) {
        gs.info('findAndCreateTask - error: ' + e);
    }
},

 

If it still not prints any error, you can mark a breakpoint there and open the Script Debugger tab.

Start Debugging and you will see all the output in details steps by steps.

TaiVu_2-1699502325828.png

TaiVu_1-1699502292188.png

 

After all, if it's still blocked you to figure out the root cause, just simply use the first approach instead => Perform the second update with an Async Business Rule.

 

Cheers,

Tai Vu

 

View solution in original post

15 REPLIES 15

Tai Vu
Kilo Patron
Kilo Patron

Hi @bhargavi143 

There's couple of ways we can achieve this.

Let's define an assignment rule on the Transfer Order Task [sysrule_assignment] table to see if it works for your case.

TaiVu_0-1699283732532.png

current.transfer_order_line.transfer_order.to_stockroom.assignment_group;

 

Cheers,

Tai Vu

Hi Tai,
Thanks for replying,
I created business rule with above mentioned script but its not worked its showing one error and for the first task the assignment group was not populated whenever i closed the first task ,the assignment group populated in other tasks.
Please check the below error:

Error Message

java.sql.BatchUpdateException: (conn=3084265) Duplicate entry '94c64ed91bde7d54fd4899f4bd4bcb4f' for key 'PRIMARY'

bhargavi143_0-1699284812720.pngbhargavi143_1-1699284860277.pngbhargavi143_2-1699284899330.png

 Please check the below screenshot : I wrote before business rule in insert 

bhargavi143_3-1699284981428.png

 

Please check the above screenshots and guide me how to solve this one.

Hi @bhargavi143 

The error is because you're performing current.update() in the before business rule. Just comment this line.

 

Cheers,

Tai Vu

Hi Tai,
I commented  current.update(),the error was gone, but i didn't get assignment group value for 1st task.
Can you please suggest me how to auto populate the assignment group value in first task.