Getting list from OData via variable list
Getting list from OData via variable list
Hello,
I am preparing a report consisting of lists. The data in the list is selected by the user. So the data varies from user to user.
All data is stored in the OData database. How can I get relevant data from user with OData script?
For example, I was able to get data with a script. I just defined a variable to get some data (type is integer value). Scenario:
ODataSalesDocumentMaterials?$filter=(Id eq {contractid})
But I need all the data selected by the user. So how can I get these?
I am preparing a report consisting of lists. The data in the list is selected by the user. So the data varies from user to user.
All data is stored in the OData database. How can I get relevant data from user with OData script?
For example, I was able to get data with a script. I just defined a variable to get some data (type is integer value). Scenario:
ODataSalesDocumentMaterials?$filter=(Id eq {contractid})
But I need all the data selected by the user. So how can I get these?
-
- Posts: 6651
- Joined: Tue Mar 20, 2018 5:34 am
Re: Getting list from OData via variable list
Hello,
You can use the Request From User option for your variable.
Thank you.
You can use the Request From User option for your variable.
Thank you.
-
- Posts: 4
- Joined: Tue Apr 30, 2024 5:24 am
Re: Getting list from OData via variable list
Hello. I have a similar issue too. In my NextJS project I'm sending parameters like this array of object:
After initializing ReportJS, I set parameters to variables like this:
I set my variable type integer list on Stimulsoft ReportJS. But I can't iterate to filter data. Here is my scenario:
I assume that Stimulsoft reads my variable like:
Is there a way to loop array to query like this?:
Code: Select all
[{key: "idList", value: [1001, 1002, 1003]}]
Code: Select all
parameters?.forEach((parameter: any) => {
const variable = report.dictionary.variables.getByName(parameter.key);
if (variable) {
variable.valueObject = parameter.value;
}
});
Code: Select all
OData_UsersTable?$filter=(Id in ({idList})
Code: Select all
OData_UsersTable?$filter=(Id in ([1001, 1002, 1003])
Code: Select all
OData_UsersTable?$filter=(Id in (1001, 1002, 1003)
-
- Posts: 6651
- Joined: Tue Mar 20, 2018 5:34 am
Re: Getting list from OData via variable list
Hello,
In this case, you should the ToQueryString() function for your variable:
{idList.ToQueryString()}
Thank you.
In this case, you should the ToQueryString() function for your variable:
{idList.ToQueryString()}
Thank you.
-
- Posts: 4
- Joined: Tue Apr 30, 2024 5:24 am
Re: Getting list from OData via variable list
I tried this approach but it didn't solve my problem. It returns "400: Bad Request". Might be there another issue? Am I doing wrong in NextJS to set variable? Can you check this:Lech Kulikowski wrote: ↑Thu May 02, 2024 5:00 pm Hello,
In this case, you should the ToQueryString() function for your variable:
{idList.ToQueryString()}
Thank you.
Code: Select all
parameters?.forEach((parameter: any) => {
const variable = report.dictionary.variables.getByName(parameter.key);
if (variable) {
variable.valueObject = parameter.value;
}
});
-
- Posts: 6651
- Joined: Tue Mar 20, 2018 5:34 am
Re: Getting list from OData via variable list
Hello,
Please check the following code for the List variable:
Thank you.
Please check the following code for the List variable:
Code: Select all
var newVariable = new Stimulsoft.Report.Dictionary.StiVariable();
newVariable.name = "Variable";
newVariable.alias = "Variable";
newVariable.type = Stimulsoft.System.StimulsoftStringList;
newVariable.requestFromUser = true;
var di = new Stimulsoft.Report.Dictionary.StiDialogInfo();
di.allowUserValues = false;
di.keys = ["1", "2", "3", "4"];
di.values = ["1", "2", "3", "4"];
newVariable.dialogInfo = di;
-
- Posts: 4
- Joined: Tue Apr 30, 2024 5:24 am
Re: Getting list from OData via variable list
I tried this method too, but no chance. I set the query as below from edit menu. It returns data when I click Run button, but I can't pass the value from my UI.Lech Kulikowski wrote: ↑Thu May 02, 2024 7:46 pm Hello,
Please check the following code for the List variable:Thank you.Code: Select all
var newVariable = new Stimulsoft.Report.Dictionary.StiVariable(); newVariable.name = "Variable"; newVariable.alias = "Variable"; newVariable.type = Stimulsoft.System.StimulsoftStringList; newVariable.requestFromUser = true; var di = new Stimulsoft.Report.Dictionary.StiDialogInfo(); di.allowUserValues = false; di.keys = ["1", "2", "3", "4"]; di.values = ["1", "2", "3", "4"]; newVariable.dialogInfo = di;
Code: Select all
OData_UsersTable?$filter=Id in ({idList.ToQueryString()})
Code: Select all
$filter: Id in ()
Also, here is my variable settings if it's helpful:
- Attachments
-
- Screenshot 2024-05-03 at 15.37.25.png (25.99 KiB) Viewed 6736 times
-
- Posts: 6651
- Joined: Tue Mar 20, 2018 5:34 am
Re: Getting list from OData via variable list
Hello,
Please provide more detailed information on how you load and run reports, how do you send parameters for the report, etc.
Thank you.
Please provide more detailed information on how you load and run reports, how do you send parameters for the report, etc.
Thank you.