Skip to Content

How can I skip the Simulate event of aftermodify?

Hi experts,

My objective is replace the material ID according to the Product Category when run the "Migration of Materials" , for example:

when category is 4041, the material ID is first 404101, and 404102...

when category is 4042, the material ID is first 404201, and 404202...

so the user just give a temp id at the material ID template, and the script get the max ID of category and offer the new material ID.

I use the aftermodirfy event of BO material, and use the NumberRange.DrawNumber() to get next number.

Now the issue is the import has two steps:Simulate and Execute.

so the NumberRange.DrawNumber() will run twice, and lose a number.

Any idea to skip the Simulate event of aftermodify?

Best Regards,

Benny

3czg8.png (8.0 kB)
Add comment
10|10000 characters needed characters exceeded

  • Hi experts,

    Or maybe someone can tell me when run the aftermodify event of material, how can check it is Simulate or Execute? Thanks.

    Best Regards,

    Benny Huang

  • Get RSS Feed

2 Answers

  • Best Answer
    Jan 03 at 01:31 AM

    Not a beautiful solution, but one workaround could be to run until the simulation step the first time around, to find and fix errors, and then to close the migration and run a second time, this time directly by using the button 'Execute data migration immediately'. Doing this might 'refresh' your number range logic so that the actual max number is picked up again for the second run. (Not sure if this works, but you might like to try).

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Rohan,

      Thanks for your help.

      Yes, the IDs generated during simulation are discarded, So the parallel processing is OK. And I test the migration again and again, it runs as the requirement.

      Best Regards,

      Benny Huang

  • Jan 03 at 03:16 PM

    There are multiple ways to archive your goal ;-).

    Idea 1: Disable the numbering on demand

    You could implement an Script behavior based on the current user or some UI switch assigned to the user to enable/ disable your numbering so that the numbering is disabled while the simulation.

    Process with this code extension:

    • User with disabled numbering simulates
    • User with normal numbering behavior imports

    The Pro on this way is that this method works also if other users are already "normaly" using the system and they need the numbering

    Idea 2: Reset the numbering on demand

    Create an simple numbering management so that you can reset the NumberRanges as you want.

    Add comment
    10|10000 characters needed characters exceeded