Page 1 of 1

Loop Mapping for Dynamic Object Passing

Posted: Wed Aug 05, 2015 8:26 am
by Jack Bua

I want to pass a value to a label in a list depending on another value in the same LSV object. the object in the LSV for the date is the same as the status object value+ _date, lowercased. So if the status of one list item is Pending then its date is in the object pending_date. Status is also in the LSV along with the dates.
I have this code on the mapping from the LSV's object:

var stat = value.status;
var code = stat+"_date";
code = code.toLowerCase();
var t = value

Code: Select all

; 
 var d = new Date(t); 
 var date = (d.getMonth() + 1) + "/" + d.getDate() + "/" + d.getFullYear(); 
 return date; 

 and it works, but only on the first list item 

  [url=https://d2r1vs3d9006ap.cloudfront.net/s3_images/1251061/2015-08-0503_08_36-MobilePreview.png?1438762935][img]https://d2r1vs3d9006ap.cloudfront.net/s3_images/1251061/2015-08-0503_08_36-MobilePreview_inline.png?1438762935[/img] [/url] 

 How can I get this to work for all the items in the list?

Loop Mapping for Dynamic Object Passing

Posted: Wed Aug 05, 2015 9:59 am
by Serhii Kulibaba

Hello Jack,

Could you send us screenshot from service's test tab (with response data) and response parameters?
It looks like you have items without "status" parameter.


Loop Mapping for Dynamic Object Passing

Posted: Wed Aug 05, 2015 3:23 pm
by Jack Bua

All of my items have a "status" value.

I also have this code running to filter the records, just not in test:

var whereObject = {location_ptr: {"$inQuery": {_id: value } }, "status_value": {$lt: 7} };
return JSON.stringify(whereObject);


Loop Mapping for Dynamic Object Passing

Posted: Wed Aug 05, 2015 3:29 pm
by Jack Bua

Loop Mapping for Dynamic Object Passing

Posted: Wed Aug 05, 2015 3:37 pm
by Jack Bua

Image

All of my items have a "status" value.
I also have this code running to filter the records, just not in test:

var whereObject = {location_ptr: {"$inQuery": {_id: value } }, "status_value": {$lt: 7} };
return JSON.stringify(whereObject);

The issue is occurring with the usage of:
value

Code: Select all

 since changing it to a static definition luch as value.pending_date works without issue. 
 No errors in console either.

Loop Mapping for Dynamic Object Passing

Posted: Sun Aug 09, 2015 6:54 pm
by Serhii Kulibaba

Please check value of the codevalue

Code: Select all

/code variable. It looks like incorrect date variable. 

 You can add console.log. e.g.: 

 console.log(value[code]);

Loop Mapping for Dynamic Object Passing

Posted: Sun Aug 09, 2015 7:29 pm
by Jack Bua

Thank you for your reply Sergiy.

Code never was intended to be a date variable. it is the string name for the object in value that is a date variable. Variable t is the date variable.

I could not figure it out so I just ended up solving it by using an much more uglier approach of case and switch to fix this issue.