Hello,
Setup:
I created a table with 4 columns (see attachment)
thats the definition of the array:
private OfficecheckerQActionRow CreateEventRow(string primaryKey, string workersName,int status)
{
OfficecheckerQActionRow row = new OfficecheckerQActionRow
{
Officecheckerinstance_1001 = primaryKey,
Workersname_1002 = workersName,
Statusoftheworker_1003 = status,
};return row;
}
with the 4th column "click .. if u are in the Office"(param id:1004)
i want change the 3rd column "show .. worker in office" (param id:1003)
The button (id:1004) triggers a QAction with this code:
QAction 51 getting triggered by param 1004 (Btn)
public static void Run(SLProtocol protocol)
{
try
{int outofficeparam = Convert.ToInt32(protocol.GetParameter(1003));
outofficeparam = 1;
protocol.SetParameter(1003, outofficeparam);}
catch (Exception ex)
{
protocol.Log($"QA{protocol.QActionID}|{protocol.GetTriggerParameter()}|Run|Exception thrown:{Environment.NewLine}{ex}", LogType.Error, LogLevel.NoLogging);
}
}
How can i toggle the 3rd column during pressing the button to "in office" and "out of office"?
My 2nd Question is:
How can i display logs for debugging if the button triggered or values changed internal?
thank you in advance
Hi,
The primary key is not specified in the QAction when getting/setting parameter 1003. To know the primary key for the row that was clicked on, specify row="true" on the QAction and inside the QAction get the primary key by calling string key = protocol.RowKey(); . Then get/set parameter 1003 by calling protocol.GetParameterIndexByKey and protocol.SetParameterIndexByKey with the pid being the id of the table (not the column pid) and also include the primary key.
If the write parameter is the only thing that would be modifying parameter 1003 then the QAction could be omitted by using a togglebutton instead. Every time the write is clicked, the read will toggle to the other value, with setter="true" the value will be immediately set without the need of the QAction to process the write value. For more info see documentation here.
Logging can be consulted in the System Center.
Regards,
As iID is the id of the table and iY is the 1-based position of the column, the call should be protocol.SetParameterIndexByKey(1000, key, 3, outofficeparam);
“Console” cannot be used in a QAction. To write out logging, this can be done with a protocol.Log message. See help here: https://docs.dataminer.services/develop/api/types/Skyline.DataMiner.Scripting.SLProtocol.Log.html#Skyline_DataMiner_Scripting_SLProtocol_Log_System_String_
Thank you for your answer again,
I just realized that if I press the button inside the table, it doesn’t do anything
I attempted to display information to check if the Row key has a value or the button is triggered
“protocol.ShowInformationMessage(“try to modify param”);”
the message it’s not appearing.
I created a button (id:123) outside the table and execute the same QAction the notification appears
after that, i print the “key” the value is empty:
————————————–
string key = protocol.RowKey();
protocol.ShowInformationMessage(key);
————————————–
how can i print values and messages in the Information events (dataminer Cube) ?
-When the QAction does not get executed for the button inside the table then it is most probably because the row=”true” attribute is not defined on the QAction.
-About the protocol.RowKey() that is empty for the button outside of the table: this is normal as a rowkey is only available for something in a table, when it is outside of the table then there is no row.
-For the information events: I don’t immediately know how to do this from a QAction as QActions typically write out logging and not spam the information events. I suggest if this needs to be known that a new question is created for this as this seems to be going off topic from the original question.
Okay thank you very much
its works now
how can i close the ticket?
Thank you very much for the explanation, I just figure it out to modify a value in a table with QActions (an exercise for myself), later I want to write a C# toggle function by my own if the worker in and out of office.
I am still struggling to modify the value cause in the definition of the “bool SetParameterIndexByKey(int iID, string key, int iY, object value);” is very confusing which ID he needs.
iID says the ID of the table param
————————————
My table: Param 1000
————————————
That’s my code for now:
————————————- QAction
string key = protocol.RowKey();
int outofficeparam = Convert.ToInt32(protocol.GetParameterIndexByKey(1003,key,2));
Console.WriteLine(“getting office param”);
Console.WriteLine(“this is param what we got”,outofficeparam);
outofficeparam = 1;
protocol.SetParameterIndexByKey(1003, key,2,outofficeparam);
Console.WriteLine(“after set”);
————————————
I wanted to ask how can I print the values that I got in Dataminer?
Like in C# with “Writeline()”