Getting Error: Cannot read property "variables" from null,Detail: Cannot read property "variables" from null

Community Alums
Not applicable

Hi @Ankur Bawiskar,

I am getting this error "Error: Cannot read property "variables" from null,Detail: Cannot read property "variables" from null" in flow designer while using flow designer for creating new user.

code:

var nameProvided = current.variables.employee_name;
var names = nameProvided.split(' ');
var firstName = names[0];
var lastName = names[1];
var userName = firstName.charAt(0)+lastName;
var isUnique = false;
var userNameUsed = '';
var email = '';


var gr0 = new GlideRecord('sys_user');
gr0.addQuery('username', userName);
gr0.query();
if (!gr0.next()) {
isUnique = true;
userNameUsed = userName;
email = firstName + '.' + lastName + '@XYZ.com';
}



var i=1;
while(isUnique == false)
{
var gr2 = new GlideRecord('sys_user');
gr2.addQuery('username', userName + i);
gr2.query();
if (!gr2.next()) {
isUnique = true;
userNameUsed = userName + i;
email = firstName + '.' + lastName + i+'@XYZ.com';
}
else
{
    var gr2 = new GlideRecord('sys_user');
    gr2.addQuery('username', userName + ++i);
    gr2.query();
    if (!gr2.next()) {
    isUnique = true;
    userNameUsed = userName + i;
    email = firstName + '.' + lastName + i+'@XYZ.com';   
}
}
}

 

 

1 ACCEPTED SOLUTION

Hi,

Since yours is a custom action refer this link which would give you an understanding of input, output etc

Custom Action in ServiceNow Flow Designer

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

21 REPLIES 21

Pranesh072
Mega Sage
Mega Sage

try this format 

 

var field1 = fd_data.trigger.current.variables.variable_name;

 

var nameProvided = fd_data.trigger.current.variables.employee_name;

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

the syntax to get variable values is this

var nameProvided = fd_data.trigger.request_item.variables.employee_name;

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Community Alums
Not applicable

Hi @Ankur Bawiskar 

New error occurs "java.lang.IllegalArgumentException: variables.employee_name is not a valid dot-walk for record".

Hi,

can you help knowing this

1) your flow is on which table

2) is the variable name correct

the syntax to get variable value should work fine

fd_data.trigger.request_item.variables.<variableName>

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader