Solved

JavaScript - adding rows to array from SOAP call fails - TypeError: Cannot set property "0.0" of undefined to ""

Posted on 2013-10-28
3
864 Views
Last Modified: 2013-10-30
Background:  This is an excerpt from the  Post_Execution Code segment from a CA Technologies Process Automation custom operator. "Get CI Details Process"

The upstream inputs to this SOAP call are correct and this code works:

Process.CI_Length__ = Process[OpName].SelectDataResponse.UDSObject.length;
for ( j = 0; j < Process[OpName].SelectDataResponse.UDSObject.length; j++ )
{
  str = "row" + j;
  Process[OpName].Rows[str] = newValueMap();
  var myAttributes = new Array();
  myAttributes = Local[IconName].SelectDataResponse.UDSObject[j].Attributes[0].Attribute;
  
  Process.CI_Name__[j] = myAttributes[0].AttrValue[0].text_;
  Process.CI_Support_Cont1_Name__[j] = myAttributes[1].AttrValue[0].text_;
  Process.CI_Support_Cont2_Name__[j] = myAttributes[2].AttrValue[0].text_;
  Process.CI_Support_Cont3_Name__[j] = myAttributes[3].AttrValue[0].text_;
  Process.CI_Network_Cont_Name__[j] = myAttributes[4].AttrValue[0].text_;
  Process.CI_UUID__[j] = myAttributes[5].AttrValue[0].text_;
  
  Process.OperatorResultCode__ = "SUCCESS";
}

Open in new window


However, when I add 3 new inputs to the call and then try to capture them in the response:
 
  Process.CI_Length__ = Process[OpName].SelectDataResponse.UDSObject.length;
for ( j = 0; j < Process[OpName].SelectDataResponse.UDSObject.length; j++ )
{
  str = "row" + j;
  Process[OpName].Rows[str] = newValueMap();
  var myAttributes = new Array();
  myAttributes = Local[IconName].SelectDataResponse.UDSObject[j].Attributes[0].Attribute;
  
  Process.CI_Name__[j] = myAttributes[0].AttrValue[0].text_;
  Process.CI_Support_Cont1_Name__[j] = myAttributes[1].AttrValue[0].text_;
  Process.CI_Support_Cont2_Name__[j] = myAttributes[2].AttrValue[0].text_;
  Process.CI_Support_Cont3_Name__[j] = myAttributes[3].AttrValue[0].text_;
  Process.CI_Network_Cont_Name__[j] = myAttributes[4].AttrValue[0].text_;
  Process.CI_UUID__[j] = myAttributes[5].AttrValue[0].text_;
  Process.CI_Med_Risk_App_Group__[j] = myAttributes[6].AttrValue[0].text_;
  Process.CI_High_Risk_App_Group__[j] = myAttributes[7].AttrValue[0].text_;
  Process.CI_QA_App_Group__[j] = myAttributes[8].AttrValue[0].text_;
  
  Process.OperatorResultCode__ = "SUCCESS";
}

Open in new window


I get the error in the subject line.

I have verified the new input parameters and responses are correct both via SoapUI and by examining the response prior the execution of the code.

Based on my search on the error, the new variables are never being defined.  The "0.0" made me think it was a type error however, the responses from myAttributes[1]-[4] are exactly the same type.  These are UUID's as strings, even if they can begin with number.  The values are not NULL nor empty strings.
0
Comment
Question by:shadowbreeze
  • 2
3 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 39608279
add the following just before the << for >> loop :
if(!Process.CI_Med_Risk_App_Group__) Process.CI_Med_Risk_App_Group__ = [];
if(!Process.CI_High_Risk_App_Group__) Process.CI_High_Risk_App_Group__ = [];
if(!Process.CI_QA_App_Group__) Process.CI_QA_App_Group__ = [];

Open in new window

0
 

Author Comment

by:shadowbreeze
ID: 39610446
Adding the identity test and then explicitly declaring the array did make the error message disappear, but the new array elements are not populated.

I can't find anywhere upstream of this where the previous elements were explicitly declared. (I'm not saying they aren't - just that I haven't found them).
0
 

Author Closing Comment

by:shadowbreeze
ID: 39611720
This does resolve the issue.  (I had continued working on it before your post and introduced a typo later in the code block - so that was why it wasn't capturing the response).
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
count download link and run update query 9 56
Sums of coloumns in html/java 15 67
Popup to change image and store url in database 2 30
Add Context Menu Item 4 44
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now