2020 SP5 Task not working in 2022 SP2

Library for macros
shmare12358
Posts: 5
Joined: Thu May 26, 2022 12:09 pm
Answers: 0

2020 SP5 Task not working in 2022 SP2

Unread post by shmare12358 »

We are using PDM and we have a transition in our workflow that runs a task (with custom script) that checks the solidworks part file out of the vault, rebuilds all configurations of the file, saves it and then checks it back in.

This task was working with SW2020 SP05. We just updated to SW2022 SP02 and it is no longer working.

Anyone know what changes might be required for a task/script to work with 2022 that worked with 2020?

The code I used was created by @gupta9665 which I modified and added some code by Marco Tulio Ramos Filho. Since the SolidWorks forum has changed I am unable to find the original posts. message/771600.

Any help would be greatly appreciated.

Garret
Attachments
TaskScript-CheckoutRebuildSaveCheckin.txt
code for custom script used in task
(6.32 KiB) Downloaded 198 times
User avatar
bnemec
Posts: 1944
Joined: Tue Mar 09, 2021 9:22 am
Answers: 10
Location: Wisconsin USA
x 2546
x 1400

Re: 2020 SP5 Task not working in 2022 SP2

Unread post by bnemec »

shmare12358 wrote: Thu May 26, 2022 12:18 pm We are using PDM and we have a transition in our workflow that runs a task (with custom script) that checks the solidworks part file out of the vault, rebuilds all configurations of the file, saves it and then checks it back in.

This task was working with SW2020 SP05. We just updated to SW2022 SP02 and it is no longer working.

Anyone know what changes might be required for a task/script to work with 2022 that worked with 2020?

The code I used was created by @gupta9665 which I modified and added some code by Marco Tulio Ramos Filho. Since the SolidWorks forum has changed I am unable to find the original posts. message/771600.

Any help would be greatly appreciated.

Garret

Can you provide anything more than "it is no longer working" ? Any error dialogs or indications? Does it do anything? nothing? Does it manage to check the file out?
shmare12358
Posts: 5
Joined: Thu May 26, 2022 12:09 pm
Answers: 0

Re: 2020 SP5 Task not working in 2022 SP2

Unread post by shmare12358 »

It does not give me any error messages. When I push the file through the transition that triggers the task it appears that everything runs fine and the file explorer shows the "Date Modified" as being changed to today's date but when I open the file I still get the "Older version file" warning.
image.png
image.png (15.14 KiB) Viewed 2769 times

I just did some additional testing and found the following results.

Currently my workflow looks like this:
image.png
Transition the file from "Purchased parts" to "FromPurchasedParts" in my "RebuildSWFiles" workflow.
Purchased parts DOES NOT have check out permissions. No actions are taken during this transition.
image.png
The file is then sorted and Auto transitioned back to "PURCHASED PART" in the "Dwgs - Purchased Parts" workflow. (original state).
During this transition the action to run the task "Rebuild Part Model" is taken.
This is not working right now.

But during my testing just now I changed the permission in the PURCHASED PART state to allow file check outs and then just ran the task on the file (right click) and it seems to work. So something is not hapenning right when I transition it.
User avatar
bnemec
Posts: 1944
Joined: Tue Mar 09, 2021 9:22 am
Answers: 10
Location: Wisconsin USA
x 2546
x 1400

Re: 2020 SP5 Task not working in 2022 SP2

Unread post by bnemec »

Thank you for the additional info.

Can you confirm that the task is creating a new version of the file?

This task, is it running on user computer or task host machine?

If you can see SW rebuilding the configs but still getting that warning then I'm guessing it fails to save (no write access to file, perhaps due to not checked out).

The PDM Modified date, I believe, is for the PDM Document, so any metadata change (including state change) will update that. AFAIK it doesn't imply the file itself has been modified.

It seems most of the time with PDM if something is not working, it's permissions problem. I'm assuming you've confirmed that the user that is running the task has checkout permission for state and file location?
shmare12358
Posts: 5
Joined: Thu May 26, 2022 12:09 pm
Answers: 0

Re: 2020 SP5 Task not working in 2022 SP2

Unread post by shmare12358 »

Thanks.

When I transition the file through the workflow and have checkout permissions enabled in the "Purchased Parts" (current state) it is creating a new version. And the last Event in the File History shows "The file was checked in!"
image.png
When I transition the file through the workflow and DO NOT have checkout permissions enabled in the "Purchased Parts" (current state) it is creating a new version. But the last Event in the File History DOES NOT show "The file was checked in!"

The task is running on the users computer.

So it looks like you are right and even though I have check out permission in the "FromPurchasedParts" state when the auto transition triggers I think the file is moving back to the "Purchased Parts" state (which does not have check out permissions enabled) before the task is completed therefore no check out permission and no file update.

So I need to figure out a way to ensure the task completes before the file transitions.

Something must have changed between 2020 and 2022 because this used to work fine in 2020.
Attachments
image.png
User avatar
bnemec
Posts: 1944
Joined: Tue Mar 09, 2021 9:22 am
Answers: 10
Location: Wisconsin USA
x 2546
x 1400

Re: 2020 SP5 Task not working in 2022 SP2

Unread post by bnemec »

That's odd. I'm pretty sure that all of the actions are completed >before< the file is transitioned. Unless they changed that for some reason, intentional or not.

Which transition exactly are you doing the action in? Can you post screen shot of the transition and action dialogs?
shmare12358
Posts: 5
Joined: Thu May 26, 2022 12:09 pm
Answers: 0

Re: 2020 SP5 Task not working in 2022 SP2

Unread post by shmare12358 »

  • The file starts out in the "Purchased Part" state of the "Dwgs - Purchased Parts" workflow. There are no checkout permissions in this state.
  • I manually transition the file to the "FromPurchasedParts" state of the "RebuildSWFiles" workflow via the workflow link. No actions are performed on this transition. There are checkout permissions in this state.
  • The file is automatically transitioned to the Workflow Link which sends it back to the original workflow and state ("Purchased Part" state of the "Dwgs - Purchased Parts" workflow).
  • The Rebuild Files task is triggered by this automatic transition.
  • It takes a while for the task to start and by that time the file is already back in the original state which has no checkout permission.
image.png

I have created a work around, although it is not very elegant, where I added an additional state and automatic transition with a condition that a flag must be set (variable value = 1). The file starts out with the flag not set (variable value = 0). I then have a dispatch setup to run on file check out which then sets that flag (variable value = 1). This means that the file will not go through the second automatic transition until the task has checked the file back in, at which time the flag is now set and the file will automatically transition back to the original state.

I would rather not have to have a dispatch.

Obviously, SW must have changed something because my workflow and task worked fine in 2020 before I updated to 2022.

Thanks for you time, at least hopefully this thread will help someone else. The only other way I could see getting rid of the dispatch is if I could set the variable value at the end of the task with some script so that it sets the flag after the file is checked out by the task. I'm a total hack when it comes to code so I'm not sure if that is possible.
User avatar
AlexB
Posts: 501
Joined: Thu Mar 18, 2021 1:38 pm
Answers: 28
x 268
x 445

Re: 2020 SP5 Task not working in 2022 SP2

Unread post by AlexB »

I'm not sure if it helps, but I found that when trying to run some code with a custom add-in for PDM that it didn't behave like I expected. I don't have a point of reference though since I developed this on 2021 SP5.

I noticed that when I have several automatic state changes in a row, that my add-in isn't called between each state change. It appears that PDM transitions the file all the way through to the final destination state, and then called my add-in that hooks the state change events with every automatic transition one at once, after the file had been transitioned.

I wanted to set variables for the states between automatic transitions and it wasn't happening. When I changed from automatic to manual transitions, it worked exactly as expected. Perhaps that's somewhat of the root of your issue if that's changed from previous versions of PDM, but again I have no way of going back and testing older installations.
User avatar
bnemec
Posts: 1944
Joined: Tue Mar 09, 2021 9:22 am
Answers: 10
Location: Wisconsin USA
x 2546
x 1400

Re: 2020 SP5 Task not working in 2022 SP2

Unread post by bnemec »

AlexB wrote: Fri May 27, 2022 9:37 am I'm not sure if it helps, but I found that when trying to run some code with a custom add-in for PDM that it didn't behave like I expected. I don't have a point of reference though since I developed this on 2021 SP5.

I noticed that when I have several automatic state changes in a row, that my add-in isn't called between each state change. It appears that PDM transitions the file all the way through to the final destination state, and then called my add-in that hooks the state change events with every automatic transition one at once, after the file had been transitioned.

I wanted to set variables for the states between automatic transitions and it wasn't happening. When I changed from automatic to manual transitions, it worked exactly as expected. Perhaps that's somewhat of the root of your issue if that's changed from previous versions of PDM, but again I have no way of going back and testing older installations.
The two of these together sure sound like a regression where PDM is not waiting for a task to return when called in a transition action. Did they add some setting in the Task Setup or Transition Action page and set default behavior of the new "feature" to be turned on? If it's not a new "feature" that's enabled by default then I'd argue it's a bug. When our VAR was teaching me about Task Add-ins on transitions it was important that all the actions are caried out in order and one at a time and all before the change state. Otherwise we have asynchronous threads and all the headaches that go with them. For example, the add-in can get into an corrupt state as two things are changing the file metadata at the same time.

You might want to open a case with your VAR about PDM changing the state before the transition actions are completed. Best would be to prove out that other transition actions suffer from same problem and leave the custom add-in out if it because they'll blame that as soon as they hear there's customer code involved.
shmare12358
Posts: 5
Joined: Thu May 26, 2022 12:09 pm
Answers: 0

Re: 2020 SP5 Task not working in 2022 SP2

Unread post by shmare12358 »

thanks for the reponses.
Post Reply