array length in Salesforce - salesforce

I'm getting error "Error Error: AddIMRConroller Compile Error: Initial term of field expression must be a concrete SObject: LIST at line 21 column 23" from below line of code .
string[] str1 = imrTable.split('\r\n');
System.debug( str1.length);

In salesforce , we need to use size() method instead of length . this is something different then Java :(

Related

template language function 'slice' expects its first parameter to be of type string in logicapps Variables

I have a requirement to slice "Dev" from below variable vmName in Azure logicapp
variable information :
Name : vmName
Type : String
Value : Dev-Testing-2
When i tried with below approach/expression :
slice(split(variables('dsvmName'),'-'),1)
error : The template language function 'slice' expects its first parameter to be of type string. The provided value is of type 'Array'. Please see https://aka.ms/logicexpressions#slice for usage details.'.
Try this (untested) ...
split(variables('dsvmName'),'-')?[0]
That will retrieve the first item in the array when you split it by a hyphen.
I have reproduced in my environment and got expected results and followed below process:
Firstly, I have taken a http trigger and then initialized as below:
Then, again I initialized as below:
indexOf(variables('vmName'), '-')
Then again initialized as below to get output:
substring(variables('vmName'),0, int(variables('emo')))
Output:

Jmeter tool create request..cannot handle array parameters and dynamically created parameters

I'm having 2 issues when trying to do the create api requests using the jmeter tool
1). How to handle an array parameter. "Versions": "$[Versions]"
getting the following error message
{"timestamp":"2020-02-14T07:18:33.720+0000","status":400,"error":"Bad
Request","message":"JSON parse error: Cannot deserialize instance of
java.util.ArrayList<java.lang.Object> out of VALUE_STRING token;
nested exception is
com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot
deserialize instance of java.util.ArrayList<java.lang.Object> out of
VALUE_STRING token\n at [Source: (PushbackInputStream); line: 15,
column: 22]
2). how to handle dynamically created time stamp parameter createtime: "${createtime}"
getting the following error message
{"timestamp":"2020-02-14T07:17:58.942+0000","status":400,"error":"Bad
Request","message":"JSON parse error: Cannot deserialize value of type
java.time.OffsetDateTime from String \"${factoryCompleteTime}\":
Failed to deserialize java.time.OffsetDateTime:
(java.time.format.DateTimeParseException) Text
'${factoryCompleteTime}' could not be parsed at index 0; nested
exception is
com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot
deserialize value of type java.time.OffsetDateTime from String
\"${factoryCompleteTime}\": Failed to deserialize
java.time.OffsetDateTime: (java.time.format.DateTimeParseException)
Text '${factoryCompleteTime}' could not be parsed at index 0\n at
[Source: (PushbackInputStream); line: 15, column: 24]
My json body looks like this.
"Versions": "$[Versions]",
"createtime": "${createtime}"
I think you should pass this Versions a little bit differently, for example if it should be a JSON Array it should look like:
"Versions": [${Versions}],
or
"Versions": ${Versions},
It appears that your ${factoryCompleteTime} variable doesn't have a value so it has been replaced by the default placeholder. Use Debug Sampler and View Results Tree listener combination in order to check the variable value, it should be in format of the OffsetDateTime to wit something like: 2007-12-03T10:15:30+01:00

Retrofit - Expected begin Object

Does anyone know how to read this file (array of array, i think??) with retrofit. Can't find any examples on the internet. Have tried
1. ArrayList
2. Collection
3. []
4. [][]
5. List
Error:
Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 3 path $[0]
File:
[[1518173474652,"0.10002000","0.10010300","0.10000100","0.10009300","51.46200000",1518173534651,"5.14685961",86,"27.11500000","2.71207304","0"],[1518173534652,"0.10009300","0.10025000","0.10009300","0.10010800","122.42800000",1518173594651,"12.25782098",123,"20.10800000","2.01471571","0"]]
I think you're parsing it as a JSON, because of the error you received :
Error: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 3 path $[0]
That file, unfortunately, is not a JSON file, it doesn't fulfill the JSON syntax requirement. To check this, copy-paste your file into any JSON formatter online and they can validate it for you.
You could try parsing it with a custom-made converter. Example here.

Size of a List in an array of lists, Standard libraries C++

I have a Array of lists declared as the following
std::array<std::list<Bot*>, 21> bots = *game->getGSM()->getSpriteManager()->getBots();
where the referenced method returns the object of that type (an array of lists of bots) however when I try to get the size and append it to a wstringstream (its a windows app) via the following method
wss << bots[i].size;
I get the following error
Error 2 error C3867: 'std::list>::size': function call missing argument list; use '&std::list>::size' to create a pointer to member
getting the address of the list by changing the line to
wss << &bots[i].size;
I get the following error
Error 2 error C2276: '&' : illegal operation on bound member function expression
I get the feeling that I am missing something very basic for C++ that I should know, and am forgetting at the time, as I have not actively coded in C++ in years.

BadArgumentError: Expected an instance or iterable of (<type 'int'>, <type 'long'>); received idofOne (a str)

I keep getting the following error :
BadArgumentError: Expected an instance or iterable of (, ); received idofOne (a str).
and have tried to convert to int() but then get a different error saying :
ValueError: invalid literal for int() with base 10: ''
What is going on? I'm using Google App Engine - and retrieving the idofOne from the html template. It is the ID representation using jinja -- and it is showing a value of "1" - so it shouldn't be empty - any suggestions???
class makeHeadings3(Handler):
def get(self):
self.render('new_entries/ADMIN_make_headings3.html')
def post(self):
idofOne = self.request.get("idofOne")
type2=self.request.get("type2")
heading2name = self.request.get("headingTwo")
description2 = self.request.get("descriptionTwo")
heading3 = self.request.get("headingThree")
#getting relevant level 1 entry by id
level_1_info=Level_1_Headings.get_by_id(idofOne)
Actually - I changed the value coming from my template from the id() to the key(). However I'm discovering that in my template from which I'm retrieving the value from is coming back empty string "". why? I see the value of the key in teh template and I'm retrieving with the correct name "keyofOne" so why is it coming back empty back to my python server code???
Key for Category Level 1
DO NOT EDIT
You could first check:
level_1_info=Level_1_Headings.get_by_id("1")
Then need to add debug in your code to see what value is returned by "idofOne"
import logging
# snip
logging.info("type "+type(idofOne))
logging.info("value "+idofOne)
I hope this helps
The below should fix it. You need to get the integer value of that id
idofOne = int(self.request.get("idofOne"))
Always when parsing post or get parameters you have to convert them to the correct type before passing them to the datastore query.

Resources