Flow Designer Error: Cannot read property "length" from undefined
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2025 08:34 AM
Hello,
I have a Flow that creates GitLab Issues for specified projects. If the project does not exist (new software is requested) then it directs the Issues to a catch-all project. I am receiving Error: Cannot read property "length" from undefined when trying to direct the issue to the catch-all project, but not when the project is specified.
Error:
GitLab Project ID is known: (works)
GitLab Project ID the catch-all project: (does not work)
Am I not allowed to use a hard-coded project ID?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2025 06:16 AM
Hi @VibertT ,
Please refer to the solution :https://www.servicenow.com/community/developer-forum/error-quot-cannot-read-property-length-from-und...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2025 07:05 AM
I have read through this and compared it to the pre-processing script for Create Issue with GitLab, and it does not contain .length
(function execute(inputs, outputs) {
var mandatoryInputs = {};
mandatoryInputs.project_id = inputs.project_id;
mandatoryInputs.title = inputs.title;
new GitlabUtils().checkIfEmpty(mandatoryInputs);
var urlParams = {};
urlParams.project_id = inputs.project_id;
new GitlabUtils().validateInputs(urlParams, outputs);
var nameValuePairs = inputs.fields.split('^');
var nameValues = nameValuePairs.reduce(function(map, pair) {
var tokens = pair.split('=');
map[tokens[0]] = tokens[1];
return map;
}, {});
nameValues.project_id = inputs.project_id;
nameValues.title = inputs.title;
if (inputs.issue_iid)
nameValues.iid = inputs.issue_iid;
outputs.payload = JSON.stringify(nameValues);
})(inputs, outputs);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2025 07:07 AM
I have read through this page. It mentions that .length was being called in the pre-processing script. I've gone through the pre-processing script for Create Issue with GitLab and it does not contain .length
(function execute(inputs, outputs) {
var mandatoryInputs = {};
mandatoryInputs.project_id = inputs.project_id;
mandatoryInputs.title = inputs.title;
new GitlabUtils().checkIfEmpty(mandatoryInputs);
var urlParams = {};
urlParams.project_id = inputs.project_id;
new GitlabUtils().validateInputs(urlParams, outputs);
var nameValuePairs = inputs.fields.split('^');
var nameValues = nameValuePairs.reduce(function(map, pair) {
var tokens = pair.split('=');
map[tokens[0]] = tokens[1];
return map;
}, {});
nameValues.project_id = inputs.project_id;
nameValues.title = inputs.title;
if (inputs.issue_iid)
nameValues.iid = inputs.issue_iid;
outputs.payload = JSON.stringify(nameValues);
})(inputs, outputs);