performWorkflowTransition on revisioning item

performWorkflowTransition on revisioning item

Aron_Thorfinnsson
Enthusiast Enthusiast
101 Views
2 Replies
Message 1 of 3

performWorkflowTransition on revisioning item

Aron_Thorfinnsson
Enthusiast
Enthusiast

Hi, I have a revision ctrl WS where I want to be able to check a box on an item release it via onEdit script. 

 

var statusUnreleased    = "Unreleased";
var actionRelease       = "Release Doc";
var actionNewVersion    = "Revise Doc";
var wsLockRev = 'WS_LOCK_REVISIONS';

lock();
function lock(){
if(!item.LOCK_REVISION || !item.descriptor.revisionList[0].working) return;


var newLockRev = createItem(wsLockRev); 
var wfItem = newLockRev.workflowItems.addItem({RELATED:item}); 

var state = item.descriptor.dvi.lifecycleState.stateName;

wfItem.lifecycle = (state === statusUnreleased) ? actionRelease : actionNewVersion;

newLockRev.performWorkflowTransition(4218); //release revision

}

 

The code everything it is suppose except the revisioning item hasn't been able to grab the revision from the item I am passing through. 

Aron_Thorfinnsson_1-1755784914032.png

is there a workaround or a way to achieve this?

  

 

0 Likes
102 Views
2 Replies
Replies (2)
Message 2 of 3

Aron_Thorfinnsson
Enthusiast
Enthusiast

Philip, with some help I managed to get this to work with this: 

 

//Documents Non Rev Ctrl by us but where we want to keep track of revisions [onEdit]
var statusUnreleased    = "Unreleased";
var actionRelease       = "Release Doc";
var actionNewVersion    = "Revise Doc";
var wsLockRev = 'WS_LOCK_REVISIONS';

prepareRelease();

function prepareRelease(){

if(!item.LOCK_REVISION || !item.descriptor.revisionList[0].working) return;

var newLock_Prop = [];
newLock_Prop.DATE = new Date();

var newLockRev = createNewItem(wsLockRev, newLock_Prop); 
var wfItem = newLockRev.workflowItems.addItem({RELATED:item}); 

var state = item.descriptor.dvi.lifecycleState.stateName;

wfItem.lifecycle = (state === statusUnreleased) ? actionRelease : actionNewVersion;

newLockRev.performWorkflowTransitionByCustomID("SUBMIT");
}


//Lock Revisions [onEdit]
//Revisioning WS onEdit:
if (item.descriptor.workflowState === "In Progress") {
    item.performWorkflowTransitionByCustomID("SUBMIT");
} else if (item.descriptor.workflowState === "auto") {
    item.performWorkflowTransitionByCustomID("COMPLETE");
} 

//Lock Revisions [wfActions]
//Revisioning WS wfActions: 
switch(customTransID){
	case 'INITIATE':
	item.TEST = Math.random();
	break; 
	
	case 'SUBMIT': 
	item.TEST = Math.random();
	item.performWorkflowTransitionByCustomID('COMPLETE');
	break;

	case 'COMPLETE':
	item.TEST = Math.random();
	break;
}

 

Aron_Thorfinnsson_1-1757509535107.png

 

0 Likes
Message 3 of 3

philipfrench
Collaborator
Collaborator

Nice work. I did not know you could do this in a single step. It never used to work.

I will remove my original comment, because that was not correct.

0 Likes