How do you Copy a Freeform Visual Task Board?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2019 11:15 AM
I used this script from a previous thread. But when I click the button it doesn't copy the board. I currently have it on the form view of an already created VTB but it doesnt work.
var VTBCloneUtil = Class.create();
VTBCloneUtil.prototype ={
initialize: function() {
},
cloneBoard: function(existingBoard) {
// Let's get the board first
var clone = new GlideRecord("vtb_board");
clone.initialize();
clone.name = "Copy of" + existingBoard.name;
clone.table = existingBoard.table;
clone.field = existingBoard.field;
clone.filter = existingBoard.filter;
// Add any other fields to clone here
var cloneSID = clone.insert(); // This will clone the lanes of the board
if (cloneSID) {
this.cloneLanes(cloneSID, existingBoard.sys_id);
}
return clone;
},
cloneLanes: function(newSID, existingSID) {
var newLane = new GlideRecord("vtb_lane");
var existingLane = new GlideRecord("vtb_lane");
existingLane.addQuery("board" , existingSID);
existingLane.insert();
while (existingLane._next()) {
newLane.initialize();
newLane.name = existingLane.name;
// Add any other fields and values here
newLane.board = newSID;
newLane.insert();
}
//choose to return something
},
type: 'VTBCloneUtil'
};
- Labels:
-
Best Practices
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2019 01:16 PM
I could get it to work in my Madrid dev, so it could be a compatibility problem or it could be some small error. Did you see anything at all happen clicking the UI Action?
And just to clarify, your UI Action that is not client-callable contains the following code from that thread you mentioned?
// Clone the board
var originalBoard = current.name;
var clonedBoard = (new VTBCloneUtil()).cloneBoard(current);
// Redirect to the new board
action.setRedirectURL(clonedBoard);
gs.addInfoMessage(gs.getMessage("Cloned from {0} board", originalBoard));
And the code you pasted above exists in a Script Include called "VTBCloneUtil"?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2019 06:33 AM
Yes, that resolved my issue. I now need help copying the members and the labels. Is that possible? I realized I was putting my UI action code in the Script Include section.