Creating Request/RITM and SCTasks from Table

Susan Davidson
Giga Guru

I have a table (u_windows_upgrade)

That has 4 columns

 

The first 3 are reference

u_user

u_computer

u_entity

 

The last is a choice

u_replace_or_upgrade

 

It is being populated by an excel upload

That part is fine

 

I have a catalog item with the sys_id 

c0e114071b704e10ed9711f72a4bcbd0
 
It has 4 variables.
 
3 are reference fields (using he same filters as the table above)
primary_contact
computer_name
entity
 
1 is a choice (display and values are the same as the choice field on the table)
is_this_a_replacement_or_windows_upgrade
 
I have a business rule that is running after insert on the u_windows_upgrade table
 

 

(function executeRule(current, previous /*null when async*/) {

createRequest();

function createRequest() {

//Create Request

var cart = new Cart();

//substitute your cat item

var item = cart.addItem('c0e114071b704e10ed9711f72a4bcbd0');

//Set Variables in your Cart Item

//substitute your req for

cart.setVariable(item, 'primary_contact','source.u_user.getvalue');

cart.setVariable(item, 'computer_name', 'source.u_computer');

cart.setVariable(item, 'is_this_a_replacement_or_windows_upgrade', 'source.u_upgrade_or_replace');

cart.setVariable(item, 'Entity', 'source.u_entity');

var rc = cart.placeOrder();

cart.description = 'Test';

var rc = cart.placeOrder();

gs.addInfoMessage('Request Item Created: ' + rc.number);

}

})(current, previous);

 

 

This is creating the request, and the catalog items fine. My name is showing up as the opened_by and the catalog item is correct and producing the correct tasks for the item

 

It is NOT however populating the variables with the information in the columns on the table...

 

I'm sure it's something super obvious but i have been looking at this for hours and cannot for the life of me figure it out. Any ideas?

 
1 ACCEPTED SOLUTION

Just a placeholder.. sorry i thought i had added that at the bottom. 

 

Where i have the items in '' are the names of the columns in the table. i have tried tablename.fieldname

current.fieldname

source.fieldname

so many different things.. none working.

Was hoping that was what someone could tell me - what I should be putting in those "source.fieldname" spaces.

View solution in original post

4 REPLIES 4

nataliya_b
Tera Guru

what is source in your code and why it is quotes? for example 'source.u_upgrade_or_replace'?

 

 

Just a placeholder.. sorry i thought i had added that at the bottom. 

 

Where i have the items in '' are the names of the columns in the table. i have tried tablename.fieldname

current.fieldname

source.fieldname

so many different things.. none working.

Was hoping that was what someone could tell me - what I should be putting in those "source.fieldname" spaces.

When you look at record XML from u_windows_upgrade table, do you see field names, reffered in the code

 

Should be like current.u_user.toString()

Also you have cart.plceOrder() twice

Susan Davidson
Giga Guru

Apparently all i needed to do was post and then i was able to resolve it... sigh (I missed a t out in a word)