How to write Dynamic Transaction names with loop count in truclient - dynamic

I want to define dynamic transaction name with a variable in it
like
for(var i=0;i<=5;i++)
LR.startTransaction("Application_TransactionLoopcount_"+myloopcount);
Truclient step1
Truclient step2
LR.endTransaction("Application_TransactionLoopcount_"+myloopcount, "Auto");
Expecting transaction like: Application_TransactionLoopcount_1
But always throwing an syntax expection
Pls advice

You should be able to do so using TC.startTransaction and TC.endTransaction.
Make sure the steps are wrapped in TC ForLoop step and you use the index variable name in your JavaScript steps.
TC.startTransaction("Transaction_LoopCount" + i);
TC.endTransaction("Transaction_LoopCount" + i, "Auto");
In case you still have an exception, it would be worth to paste the exception here as reference.

Related

Understanding PsychoPy codes for trialHandler and responses

I am new to coding, and would like help in understanding the script used by the PsychoPy program.
To be more specific, I would like to understand the codes that are in line 6 to 15. I am aware that this is used to manage the multiple trials, but I am hoping someone can help me clarify those bits? I also noted that removing the codes from line 6-8 doesn't change the experiment, but removing the codes from line 10-15 essentially stop the experiment from running.
trialsAll = data.TrialHandler(trialList=data.importConditions('trialType.xlsx'), nReps=10, method='random', name='trialsAll', dataTypes='corr')
thisExp = data.ExperimentHandler(name='Ours')
thisExp.addLoop(trialsAll) #adds a loop to the experiment
thisTrial = trialsAll.trialList[0]
if thisTrial != None:
for paramName in thisTrial.keys():
exec(paramName + '= thisTrial.' + paramName)
# Loop through trials
for thisTrial in trialsAll:
currentLoop=trialsAll
if thisTrial != None:
for paramName in thisTrial.keys():
exec(paramName + '=thisTrial.' + paramName)
My second question would be about getting responses. Is there a reason that thisResp is equalled to None?
#get response
thisResp=None
while thisResp==None:
allKeys=event.waitKeys()
Thanks a lot for any help. I appreciate it.
Regards,
Cash
if thisTrial != None:
for paramName in thisTrial.keys():
exec(paramName + '= thisTrial.' + paramName)
This code allows the use of abbreviations. For example, say your conditions file has a field called 'angle', you can refer to this directly rather than via the keys of that trial's dictionary (e.g. thisTrial['angle'] ) or using dot notation ( thisTrial.angle ). i.e., in this example:
angle = thisTrial.angle
for thisTrial in trialsAll:
is fundamental to running a psychoPy trial loop. It will cycle though each trial that is contained in the TrialHandler object that is created to manage trials, connected to a given conditions file.
#get response
thisResp=None
while thisResp==None:
allKeys=event.waitKeys()
The line 'while thisResp==None:' requires that the variable 'thisResp' actually exists if we are going to be able to check its value. So in the immediately preceding line, it is created and given an initial null value so that the next line will run OK. Note that at this stage, it is just an arbitrary variable, which doesn't have any actual connection to the subject's response. That will presumably occur later in the code, when it gets assigned a value other than None.

SQL simulator on Prolog

i need to do a SQL simulator on Prolog. i need to simulate some functions like create_table, insert, delete, update_table, select_table, drop_table, show_table, etc. I am learning how to do asserts and retracts but im getting some errors in my first function create_table(N,A) where N is the name of the table and A a list with the atributtes
An example is create_table("student",["name","lastname","age"]). This will create my table named "student" with the atributes ["name","lastname","age"].
I was searching how to work with assert and i see i need to do dynamic before making assert, then my code is.
len([],0).
len([_|T],N) :- len(T,X), N is X+1.
create_table(_, []):-!.
create_table(N, Atributos):- len(Atributos, L), dynamic N/L, assert(N(Atributos)).
But i get this error :7: Syntax error: Operator expected on this line
create_table(N, Atributos):- len(Atributos, L), dynamic N/L, assert(N(Atributos)).
What im doing wrong? excuse me, i dont speak good english.
From the error message, seems you're using SWI-Prolog....
Your code could be (note that len/2 can be replaced by the builtin length/2)
create_table(N, Atributos):-
length(Atributos, L),
dynamic(N/L),
T =.. [N|Atributos], % this missing 'constructor' was the cause of the error message
assert(T). % this is problematic
There is an important 'design' problem: the CREATE TABLE SQL statement works at metadata level.
If you do, for instance,
?- assertz(student('Juan', 'Figueira', 20)).
pretending that the predicate student/3 holds table data, you're overlapping data and metadata
using dynamic/1 and assert is a tricky non-logical aspect of Prolog, and dynamically creating dynamic predicates is really unusual. Fundamentally you cannot have a Prolog query with the predicate name as a variable e.g.
query(N,X) :- N=student, N(X).
My suggestion is you remove a layer of complexity and have one dynamic predicate 'table', and assert your SQL tables as new 'table' clauses i.e.
:- dynamic table/2.
:- assertz(table(student,['Joe','Young',18])).
query(N,X) :- table(N,X).
:- query(student,[Name,Lastname,Age]).

Zoho Creator making a custom function for a report

Trying to wrap my head around zoho creator, its not as simple as they make it out to be for building apps… I have an inventory database, and i have four fields that I call to fill a field called Inventory Number (Inv_Num1) –
First Name (First_Name)
Last Name (Last_Name)
Year (Year)
Number (Number)
I have a Custom Function script that I call through a Custom Action in the form report. What I am trying to do is upload a CSV file with 900 entries. Of course, not all of those have those values (first/last/number) so I need to bulk edit all of them. However when I do the bulk edit, the Inv_Num1 field is not updated with the new values. I use the custom action to populate the Inv_Num1 field with the values of the other 4 fields.
Heres is my script:
void onetime.UpdateInv()
{
for each Inventory_Record in Management
{
FN = Inventory_Record.First_Name.subString(0,1);
LN = Inventory_Record.Last_Name.subString(0,1);
YR = Inventory_Record.Year.subString(2,4);
NO = Inventory_Record.Number;
outputstr = FN + LN + YR + NO;
Inventory_Record.Inv_Num1 = outputstr;
}
}
I get this error back when I try to run this function
Error.
Error in executing UpdateInv workflow.
Error in executing For Each Record task.
Error in executing Set Variable task. Unable to update template variable FN.
Error evaluating STRING expression :
Even though there is a First Name for example, it still thinks there is none. This only happens on the fields I changed with Bulk Edit. If I do each one by hand, then the custom action works—but of course then the Inv_Num1 is already updated through my edit on success functions and makes the whole thing moot.
this may be one year late, you might have found the solution but just to highlight, the error u were facing was just due to the null value in first name.
you just have put a null check on each field and u r good to go.
you can generate the inv_number on the time of bulk uploading also by adding null check in the same code on and placing the code on Add> On Submt.( just the part inside the loop )
the Better option would be using a formula field, you just have to put this formula in that formula field and you'll get your inventory_number autogenerated , you can rename the formula_field to Inv Number or whaterver u want.
Since you are using substring directly in year Field, I am assuming the
year field as string.else you would have to user Year.tostring().substring(2,4) & instead of if(Year=="","",...) you have to put if(Year==null , null,...);
so here's the formula
if(First_Name=="","",First_Name.subString(0,1))+if(Last_Name =="","",Last_Name.subString(0,1)) + if(Year=="","",Year.subString(2,4)+Number
Let me know ur response if u implement this.
Without knowing the datatype its difficult to fix, but making the assumption that your Inventory_Record.number is a numeric data item you are adding a string to a number:
The "+" is used for string Concatenation - Joiner but it also adds two numbers together so think "a" + "b" = "ab" for strings but for numbers 1 + 2 = 3.
All good, but when you do "a" + 2 the system doesn't know whether to add or concatenate so gives an error.

Maximo scripting cannot load second MboSet

I've a script with an object launchpoint on INVOICELINE.
For the mbo I want to get all INVOICELINES with the same PONUM as the current MBO (since they could be in other then the current mbo's invoice)
In the script I find the PO like so: (to test for status)
from psdi.server import MXServer
from psdi.mbo import Mbo
from psdi.mbo import MboConstants
from psdi.security import UserInfo
from psdi.server import MXServer
myMXServer = MXServer.getMXServer()
userInfo = mbo.getThisMboSet().getUserInfo()
# find the PO
poSet = myMXServer.getMboSet("PO", userInfo)
poSetWhere = "ponum='" + mbo.getString("PONUM") + "' and siteid='" + mbo.getString("POSITEID") + "' and status not in " + poNoUpdate
poSet.setWhere(poSetWhere)
poMbo = poSet.getMbo(0)
which works great.
then later I do the very same for the set of invoicelines:
ilSet = myMXServer.getMboSet("INVOICELINE", userInfo)
ilSetWhere = "ponum='" + mbo.getString("PONUM") + "' and positeid='" + mbo.getString("POSITEID") + "'"
ilSet.setWhere(ilSetWhere)
ilMbo = ilSet.moveFirst()
while ilMbo is not None:
...
which results in a error on the setWhere line. Curiously, logging (which I removed for readability) indicates that ilSet contains all invoicelines records after the getMboSet (as expected), the ilSetWhere has a valid query that you can copy-paste in SQL Developer.
Does Maximo need some index or so before it can execute this setWhere?
Here is the logging result for the two setWhere strings:
ponum='4140006682' and siteid='mysite' and status not in ('CLOSED','CAN','GESLTN','ANN')
and
ponum='4140006682' and positeid='mysite'
The error I get is a generic BMXAA7837E java.lang.NullPointerException in script at line... (the line refers to the line with the ilSet.setWhere(ilSetWhere) expression. I'm out of ideas how to fix this and have no clue how to work around it.
Now we have an error to work with!
Maximo effectively insists that an INVOICELINE set has an "owner", which you have not set up in your code example. Think of an owner as a parent set. Specifically, it is the MBOSet used to fetch the current set off of. It doesn't actually have to be related to the current set, but most of the time it will be (and it makes the most sense to fetch sets that way). An owner can be injected into the set after it's fetched (to change it or trick Maximo), but this is rarely good code.
Instead of getting a fresh set (no other ties or possible data caching) from the server in its own transaction, you might be best off getting the invoiceline set off of your current MBO. I don't know your exact use case, but generally you want to do something like this instead of getting a new set like you did. At the least, it will give your new set an "owner". You may even want to make the SQL a "relationship" instead of hard-coding it.
ilSetWhere = "ponum='" + mbo.getString("PONUM") + "' and positeid='" + mbo.getString("POSITEID") + "'"
ilSet = mbo.getMboSet("$TempInvoiceLineRelationship", "INVOICELINE", ilSetWhere)
ilMbo = ilSet.moveFirst()
I'm going from memory for this code, so I don't know if it is exactly correct. That form of "getMboSet" takes three parameters. The first is a relationship name. If Maximo finds that relationship name already "registered" from this starting object, it will ignore the next two parameters and use that relationship to get you that set. If it doesn't find that relationship "registered" it registers it for the scope of this code (so you can re-use it later in this code if you wanted). The second parameter defines what destination object to create the temporary relationship to. The third parameter defines the "where clause" of this temporary relationship.
Original Answer:
What is the error you are getting?
Also, you say you log "ilSet" after the "myMXServer.getMboSet..." line? That is going to cause Maximo to run the query and load the objects into the set at that point (it waits to run the query until it has to). As a result of that, you won't see the effects of your where clause change until you "reset()" the set.

JMeter regex extractor forEach controller

I'm creating some tests with JMeter, the situation is very simple, I have a search page with a list of results, and I have to retrieve from this results some values to use in the next request.
Those results are around 350, I don't need them all.
I used the RegexExtractor to retrieve those results and it works (I setted it to retrieve just 10 results), but now I don't know how to access the results inside a LoopCounter.
The extractor put the results into a variable named Result.
The problem is that I don't know hot to build dinamically the name of a variable.
Do I have to use some function like _p()??
I can access the variable just putting the static name Result_0_g1
Inside the LoopCounter I putted also a Counter to store the loop count into the variable index
Thank you
EDIT:
SOLVED I have to write:
${__V(Result_${index}_g1)
You have to reference the variable with the function:
${__V(Result_${index}_g1)
...Just for collection.
See also this post for another implementation (case without using ForEach Controller):
ThreadGroup
HttpSampler
Regex Extractor (variableName = links)
WhileController(${__javaScript(${C} < ${links_matchNr})})
HTTPSampler use ${__V(links_${C})} to access the current result
Counter (start=1, increment=1, maximum=${links_matchNr}, referenceName=C)
Use the ForEach Controller - it's specifically designed for this purpose and does exactly what you want.
You may use ForEach Controller:
ThreadGroup
YourSampler
Regular Expression Extractor (match -1, any template)
Foreach controller
Counter(Maximum -> ${Result_matchNr} , Rf Name -> index)
LinkSamplerUsingParsedData(use -> ${__V(Result_${index}_g1)}
Now, if you want to iterate to all groups, you need another foreach to do that. As you know which group represent what value, you can use this way.