Instr method in Javascript XPages - xpages

Which method i can use in ServerSide Javascript instead of Instr method in LotusScript
Regards
Cumhur Ata

Use
yourString.indexOf(yourSubstring)
It returns a value >= 0 if yourSubstring is part of yourString.
It is the position of yourSubstring in yourString starting with 0.
This is different to LotusScript's InStr which starts with 1.

Related

Can´t find the correct class for string methods in Godot

I am trying to make my program read and edit text. I was trying to use the Position=find ( String , 0 ) method but I get the error:
The method "find" isn't declared in the current class.
I have tried different classes but I cant find the correct one.
Which would that be?
How may I find the correct class in the future?
Thanks in advance.
The find is in the String class.
From the documentation:
int find ( String what, int from=0 )
Finds the first occurrence of a substring. Returns the starting position of the substring or -1 if not found.
So what happens?
When you do Position = find(String, 0) You are calling find from which ever class your code is inside, not from String.
Furthermore, I only see one String there… Which String do you want to find in which one? You need two. Yes, find only takes one String, but it is an instance method, not a static method. You are meant to call it on the one you want to search, like this:
var position := string_in_which_you_are_looking.find(string_you_are_looking_for, 0)

Azure Logic App condition - Property contains in object within an array

value is an array with objects that have a property called skuPartNumber (string). How do I make a condition that is true when there are any objects where the skuPartNumber is equal to "X" in the array.
For your requirement, you can use contains function to implement it easily. As your screenshot shows, but need to make some changes.
First, you need to know the expression of value. It seems the value comes from "Parse JSON" in your logic app. So the expression of value should be like body('Parse_JSON')?['value']. Then use a string() function to convert it to string, then judge if it contains "skuPartNumber":"x".
The expression is string(body('Parse_JSON')?['value']).
I think the solution above is easy enough, but if you don't want to think of it as a string to judge if it contains "skuPartNumber":"x". You can also loop the value array, get each item and judge if the field skuPartNumber equals to x. Do it like below screenshot:
After the "For each" loop, use a "If" condition to judge if the variable result equals true or false.

Cognos query calculation - how to obtain a null/blank value?

I have a query calculation that should throw me either a value (if conditions are met) or a blank/null value.
The code is in the following form:
if([attribute] > 3)
then ('value')
else ('')
At the moment the only way I could find to obtain the result is the use of '' (i.e. an empty character string), but this a value as well, so when I subsequently count the number of distinct values in another query I struggle to get the correct number (the empty string should be removed from the count, if found).
I can get the result with the following code:
if (attribute='') in ([first_query].[attribute]))
then (count(distinct(attribute)-1)
else (count(distinct(attribute))
How to avoid the double calculation in all later queries involving the count of attribute?
I use this Cognos function:
nullif(1, 1)
I found out that this can be managed using the case when function:
case
when ([attribute] > 3)
then ('value')
end
The difference is that case when doesn't need to have all the possible options for Handling data, and if it founds a case that is not in the list it just returns a blank cell.
Perfect for what I needed (and not as well documented on the web as the opposite case, i.e. dealing with null cases that should be zero).

Separate number with symbol in Excel

I am looking for a function in Microsoft Excel that can separate number with symbol. For the example :
I want to separate number in this code:
12345_ABCD
I am looking for a function that can enables me to get the number (in this case 12345) without another character (in this case _ABCD).
And the problem is the the total character of number can be vary. For the example, it can be 12345_ABCD or 234_ABC or 34567_AB.
Please kindly help my problem. Thanks for your concern
If your cells always have numbers in front and then an underscore you could use this:
=Left(A1;Find("_";A1)-1)
Here is the function to get the number alone (in your case)
Public Function segregatenumber(a As String)
segregatenumber = Left(a, InStr(a, "_") - 1)
End Function
then you may use it as function in Excel cells

How do I append a value to results of #DBlookup in xpages?

How do I append a value to results of #DBlookup in xpages?
I tried this but it does not seem to work.
var v = #DbLookup("","Setup","Setup","ModRationales").push("Other 2");
return v;
It shows 6.0 in my listbox.
First of all: #DbLookup returns a string when it looks up one value only, and it returns an array when it finds multiple values. I will therefore suggest that you use the DbLookupArray() function available as a xsnippet as this function always returns an array. It has other advantages too such as optional caching of the result.
Then it is just a matter of adding elements to the array using .push() on the result returned by DbLookupArray().
Your current lookup is most likely returning a single element - which in the case of #DbLookup is a string.
Got it:
var v = #DbLookup("","Setup","Setup","ModRationales");
v.push("Other");
return v;

Resources