Help: Workflow, Run Script with scratchpad + Create Task
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2016 09:25 AM
HELP Please
I'm just going through some items that were done by a 3rd party developer while I was away from the office. I've never worked with something like this so I'm looking for some help. It doesn't work at all like any of our other workflows/ ritms / tasks and I'm getting odd behavior in the sc_task. We have a global client script that highlights our 'Additional Comments (Customer Visible)' Field Green, and it isn't working for these create tasks. Does anyone have any idea as to why? Also, we have a 'Work Notes' field where end user responses are input, and now the 'Assigned to' isn't receiving notifications that the task has been updated.
This catalog item is portal facing and allows end users to choose from a list of items:
the workflow looks like this:
Run Script sets task variables:
workflow.scratchpad.furn = Furniture();
workflow.scratchpad.store = Storage();
workflow.scratchpad.equip = Equipment();
function Furniture(){
var hFurn = "\n\nFurniture Request\n\n";
var tFurn = '';
var cFurn = 0;
if(current.variables.v_furn_desk_amt > 0){
tFurn += 'Desk: ' + current.variables.v_furn_desk_amt + '\n';
cFurn = cFurn + 1;
}
if(current.variables.v_furn_credenza_amt > 0){
tFurn += 'Credenza Amount: ' + current.variables.v_furn_credenza_amt + '\n';
cFurn = cFurn + 1;
}
if(current.variables.v_tchair_amt > 0){
tFurn += 'Task Chair: ' + current.variables.v_tchair_amt + '\n';
cFurn = cFurn + 1;
}
if(current.variables.v_dchair_amt > 0){
tFurn += 'Guest Chair: ' + current.variables.v_dchair_amt + '\n';
cFurn = cFurn + 1;
}
if(cFurn > 0){
return hFurn + tFurn;
}
else return '';
}
function Storage(){
var hStore = "\n\nStorage Request\n\n";
var tStore = '';
var cStore = 0;
if(current.varialbes.v_store_2file_amt > 0){
tStore += '2 Drawer File Cabinet: ' + current.variables.v_store_2file_amt + '\n';
cStore = cStore + 1;
}
if(current.variables.v_store_3file_amt > 0){
tStore += '3 Drawer File Cabinet: ' + current.variables.v_store_3file_amt + '\n';
cStore = cStore + 1;
}
if(current.variables.v_store_4file_amt > 0){
tStore += '4 Drawer File Cabinet: ' + current.variables.v_store_4file_amt + '\n';
cStore = cStore + 1;
}
if(current.variables.v_store_5file_amt > 0){
tStore += '5 Drawer File Cabinet: ' + current.variables.v_store_5file_amt + '\n';
cStore = cStore + 1;
}
if(current.variables.v_store_2bk_amt > 0){
tStore += '2 High Bookshelf: ' + current.variables.v_store_2bk_amt + '\n';
cStore = cStore +1;
}
if(current.variables.v_store_3bk_amt > 0){
tStore += '3 High Bookshelf: ' + current.variables.v_store_3bk_amt + '\n';
cStore = cStore + 1;
}
if(current.variables.v_store_4bk_amt > 0){
tStore += '4 High Bookshelf: ' + current.variables.v_store_4bk_amt + '\n';
cStore = cStore + 1;
}
if(current.variables.v_store_5bk_amt > 0){
tStore += '5 High Bookshelf: ' + current.variables.v_store_5bk_amt + '\n';
cStore = cStore + 1;
}
if(current.variables.v_store_peddraw_amt > 0){
tStore += 'Pedistal Drawers: ' + current.variables.v_store_peddraw_amt + '\n';
cStore = cStore + 1;
}
if(current.variables.v_store_combo_amt > 0){
tStore += 'Combo Unit(Drawers and Shelves): ' + current.variables.v_store_combo_amt + '\n';
cStore = cStore + 1;
}
if(cStore > 0){
return hStore + tStore;
}
else return '';
}
function Equipment(){
hEquip = "\n\nEquipment Request\n\n";
tEquip = '';
cEquip = 0;
if(current.variables.v_store_wh34_amt > 0){
tEquip += 'Whiteboard 3ft x 4ft: ' + current.variables.v_store_wh34_amt + '\n';
cEquip = cEquip + 1;
}
if(current.variables.v_store_wh46_amt > 0){
tEquip += 'Whiteboard 4ft x 6ft: ' + current.variables.v_store_wh46_amt + '\n';
cEquip = cEquip + 1;
}
if(current.variables.v_store_cork34_amt > 0){
tEquip += 'Corkboard 3ft x 4ft: ' + current.variables.v_store_cork34_amt + '\n';
cEquip = cEquip + 1;
}
if(current.variables.v_store_cork46_amt > 0){
tEquip += 'Corkboard 4ft x 6ft: ' + current.variables.v_store_cork46_amt + '\n';
cEquip = cEquip + 1;
}
if(current.variables.v_store_keytray_amt > 0){
tEquip += 'Keyboard Tray: ' + current.variables.v_store_keytray_amt + '\n';
cEquip = cEquip + 1;
}
if(current.variables.v_store_corner_amt > 0){
tEquip += 'Corner Maker (Black Metal Square): ' + current.variables.v_store_corner_amt + '\n';
cEquip = cEquip + 1;
}
if(current.variables.v_store_maprack_amt > 0){
tEquip += 'Map Rack: ' + current.variables.v_store_maprack_amt + '\n';
cEquip = cEquip + 1;
}
if(cEquip > 0){
return hEquip + tEquip;
}
else return '';
}
Create Task Script:
// Set values for the task in this script. Use the variable 'task' when setting additional values.
// Note: This script is run after the task values are set using the Fields, Template or Values you have specified.
//
// For example:
// task.short_description = current.short_description;
task.description = "The requested items to fill\n\n" + workflow.scratchpad.furn + workflow.scratchpad.store + workflow.scratchpad.equip + current.variables.v_comments;
task.short_description = 'Furniture Request' + ' - ' + current.variables.requested_for.getDisplayValue() + ' - ' + current.variables.v_location.getDisplayValue();
task.u_action_room_number = current.variables.v_location.getDisplayValue();
//task.comments = current.variables.v_comments

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2016 09:29 AM
I might be missing something but how is a missing field on form related to workflow ? Can you share the client script that is responsible for showing/hiding this field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2016 09:40 AM
Hello Kalaiarasan, We aren't missing any fields on the form. I have a global client script that isn't working for this item only. It works across the board for all other Catalog Items. I'm just getting some odd (maybe normal?) behavior from this 'Create Task' setup.
Here's our client script for Highlighting the additional comments field green:
Table: Task
function onLoad() {
//Highlight the 'Additional Comments' field for roled users
var table_name = g_form.tableName;
var commField = table_name + '.comments';
var commLabel = 'label.' + commField;
if(g_user.hasRoles()){
try{
gel(commField).style.backgroundColor="LightGreen"; // Additional comments field
gel(commLabel).style.color="Black"; // Additional comments variable title font color
gel(commLabel).style.fontWeight="bold"; // Additional comments variable title
if(g_user.hasRole('itil')){
changeLabel('comments', 'Additional comments (Customer visible):');
}
}catch(e){};
}
}
function changeLabel(field, newLabel){
var fieldFormName = g_form.getTableName() + "." + field;
var fieldLabelName = "label." + fieldFormName;
var ctrl = document.getElementById(fieldLabelName);
for (x in ctrl.childNodes) {
if(ctrl.childNodes[x].tagName == 'LABEL') {
var forAttr = (!isMSIE) ? ctrl.childNodes[x].getAttribute('for') : ctrl.childNodes[x].getAttribute('htmlFor'); // IE support
if (forAttr == fieldFormName){
ctrl.childNodes[x].innerHTML = newLabel;
}
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2016 09:43 AM
This line in your script checks for ITIL role,
g_user.hasRole('itil')
Is your test user having this role?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2016 09:41 AM
I've tried creating this client script on the Catalog Item itself, and it still doesn't work.