Select the final destination of the workpiece based on the conditions

 

Hello everyone! There is a question that requires your assistance to answer. I don't know how to control the final destination for transporting the workpiece based on the changes of global variables.

 

Currently, my logic setup is as follows:
Change in global variables: The worker outside the production line transporting the workpieces move from C to D (SG_Parameter_730 changes from 0 to 1);
Change in AGV destination:
  After the machine activity is completed:

    if(SG_Parameter_730==1)
    S_TargetResource="B"
    else
    S_TargetResource="A"

However, when SG_Parameter_730 = 1, the AGV will still move the workpieces to A instead of moving it to B.

This is the original document. Thank you for your assistance in advance