Set workflow model id (path) - aem

When I create a new workflow model in AEM, it gets created under /etc/workflow/models. How do I get it to be created under a different path like /etc/workflow/models/myapp ? The only way I can think of is changing the path in CRXDE after the workflow gets created. Wanted so if there is a better way to do this.

Better way to move workflow to another place would be:
go to /miscadmin#/etc/workflow/models
use button "Move..."
Unfortunately, it seems, that there is no easy way to change place, where worflows, which are created through UI, are stored. To do this you should:
override "/libs/cq/workflow/widgets/source/widget/ModelsPanel.js" in you project, where you can find action this.newAction, where you will be able to change propery parentPath to /etc/workflow/models/myapp. But you can run into troubles after upgrading to another version of AEM.
also you can be interested in service Granite Workflow Service where you can set (through /system/console/configMgr) path to your models, which should be shown in Workflow Console /libs/cq/workflow/content/console.html. (Also it's applicable to CQ 5.6.1, for some older versions, you should configure Day CQ Workflow Service).

Related

AEM 6.5 , how to change Workflow location to Model/subfolder

AEM 6.5 default location for Workflow model is : /conf/global/settings/workflow/models/MyCustomWF. How can i make the WF model location inside my project folder i.e /conf/global/settings/workflow/models/My Project/MyCustomWF.
I tried moving my model to folder via CRX. It result in Model.html page goes blank.And I cant see any option in classic or touch UI to decide the project specific location for the Workflow.
Thanks in advance.
I got the answer after multiple attempts. You just need to shift your workflow node in the folder(created by you) and go to touch UI and open the new workflow by directly hitting the Workflow MODEL and not navigating through the naviagtion Model tile. After having Model opened in the Edit mode and click on sync model. Now your workflow is in new folder created by you.

Can I change node proeprty value in a AEM custom worklfow process?

I have created a new workflow for activate later. It includes a custom workflow process step written by me. The custom step changes some properties of the payload step and then Activate Page process is called to activate the page. The changed properties are reflected in the author instance but not on the publish instance. Just wanted to confirm if this is possible or the workflow creates a copy of the node and then executes on it (like passing a parameter to a function)?
Thanks in advance :D
It should work fine, however you have to commit changes using resourceResolver.commit()

Create new work item type using VSTS Extension

Based on the documentation https://learn.microsoft.com/en-us/vsts/extend/overview?view=vsts#what-makes-up-an-extension, a VSTS extension can be used to extend the work item form.
However, I would like my extension to automatically create a new work item type once it is installed. Is this something that is possible? I can't find any documentation online that suggests how to do it.
Theoretically this is possible, the extension has a "first load" call which you can use to use the rest api to create a custom process or update the existing custom process. The REST Api to change processes isn't public yet, so you'll have to work from using fiddler to watch how the web ui does it.
Due to the way processes are linked to projects, all projects with that process will get the new work item type.
I could not find a lot of documentation online for this, but the VSS web extensions SDK(https://www.npmjs.com/package/vss-web-extension-sdk) has a REST client called 'ProcessDefinitionsRestClient' declared in the typings/tfs.d.ts file. This client has a createWorkItemType method available that looks like this:
createWorkItemType(workItemType: ProcessDefinitionsContracts.WorkItemTypeModel, processId: string): IPromise<ProcessDefinitionsContracts.WorkItemTypeModel>;.
The 'ProcessRestClient' client has methods to create a new/inherited process to which the new WIT can be added.
I have not tried it out yet, and these APIs are still in preview, but maybe they can get you started on the right path.

Clone rep:policy on AEM

I am currently working on with a solution that would be able to clone/copy/backup my existing rep:policy. 'Cause when we do some jobs it accidentally removed. I am trying to apply this kind of fix, but am failing to. It says it is an invalid path.
javax.jcr.security.AccessControlException: OakAccessControl0006: Isolated policy node. Parent is not of type [rep:AccessControllable]
final Workspace ws = session.getWorkspace();
ws.copy("/etc/commerce/products/abccompany/TvPackChannelMap/rep:policy","/tmp/nxt/TvPackChannelMap/rep:policy");
Are there other ways that I can be able to take the rep:policy thru code?
You need to make sure that your job does not touch the permissions or the rep:policy, this is the best way forward for you.
The exception could be because of /etc/commerce/products/abccompany/TvPackChannelMap/rep:policy does not exist or the user whose session you are using does not have read access to the node.
Make sure the path is correct, copy paste it to your CRX/DE to make sure it exists.
I have tried to use your code to copy a rep:policy from one node to another, works fine. But I would not* recommend copying permissions that way. The best practice is to use the Access Control Management API for all things permissions.
You can check, install and use the access control tool from netcentric. It offers a jmx interface for exporting AC entries and maybe also some APIs you could use to implement your custom solution.
The Other approach is to retrieve the ACL permissions through the query language.
For example, SELECT * FROM [rep:ACL] or SELECT * FROM [rep:ACE] where [rep:principalName] is not null should give you the results.
For more information, I would recommend you to check the ACS commons ACL Packager Implementation which is available on GitHub.
Reference Link - https://github.com/Adobe-Consulting-Services/acs-aem-commons/blob/master/bundle/src/main/java/com/adobe/acs/commons/packaging/impl/ACLPackagerServletImpl.java

creating a new workflow by using the existing workflow - Modifications are not Saved

Am creating a new workflow by using the existing workflow ( i.e. By copying the existing workflow under /etc/workflow/models/).
But when I do this the newly created workflow is not saved for any future modifications. Observed that the newly created workflow is having a version as jcr:rootVersion and also the model is having the jcr:predecessors property of Type Reference[] is having a value as shown in below screenshot. Can’t we reuse the existing models in the way which I am trying ? or how to restrict the value ?
modification in jcr are not the best supported ones. If you want to create a new workflow use the workflow console, create a new workflow and add the steps you want to reuse. Also you can reuse workflow by adding them to a container step. I'm not sure which one do you want to use, if you want to expand an already existing workflow then go on and create a new one and add the pages, if you just want to call an already existing workflow than use the container step. Take care, the container step will generate a new workflow instance from the sub workflow and the main workflow won't wait for the sub-workflow to finish.