BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
If I export a query from QueryBuilder with multiple groups and conditions to json, then reload the json into a new queryBuilder object, the groups are not maintained. The group names are not the same for each element in each group. And sometimes the groupIds are the same across two groups.
Here is the method I am using to load the exported json (initialJson):
public void LoadInitialJson()
{
RuleModel ruleModel = Newtonsoft.Json.JsonConvert.DeserializeObject<RuleModel>(initialJson); QueryBuilderObj.Reset();
QueryBuilderObj.SetRules(ruleModel.Rules, "and");
}
Code to export the json:
JsonSerializer.Serialize(QueryBuilderObj.GetRules());
Here is the intial json which was exported :
{
"Condition": "and",
"Field": null,
"Label": null,
"Not": false,
"Operator": null,
"Type": null,
"Value": null,
"Rules": [
{
"Condition": null,
"Field": "EmployeeID.ID1",
"Label": "ID1",
"Not": null,
"Operator": "equal",
"Type": "Number",
"Value": 4,
"Rules": null,
"RuleId": "querybuilder_group0_rule0"
},
{
"Condition": null,
"Field": "FirstName",
"Label": "First Name",
"Not": null,
"Operator": "endswith",
"Type": "String",
"Value": "d",
"Rules": null,
"RuleId": "querybuilder_group0_rule1"
},
{
"Condition": "or",
"Field": null,
"Label": null,
"Not": null,
"Operator": null,
"Type": null,
"Value": null,
"Rules": [
{
"Condition": null,
"Field": "LastName.ID1",
"Label": "ID1",
"Not": null,
"Operator": "equal",
"Type": "Number",
"Value": 2,
"Rules": null,
"RuleId": "querybuilder_group1_rule2"
},
{
"Condition": null,
"Field": "Country",
"Label": "Country",
"Not": null,
"Operator": "equal",
"Type": "Object",
"Value": "England",
"Rules": null,
"RuleId": "querybuilder_group1_rule3"
}
],
"RuleId": null
},
{
"Condition": "or",
"Field": null,
"Label": null,
"Not": null,
"Operator": null,
"Type": null,
"Value": null,
"Rules": [
{
"Condition": null,
"Field": "UserActions.Click",
"Label": "Click",
"Not": null,
"Operator": "equal",
"Type": "Number",
"Value": 2,
"Rules": null,
"RuleId": "querybuilder_group2_rule4"
}
],
"RuleId": null
}
],
"RuleId": null
}
After loading the above json, here is the export of the Query into a new json:
{
"Condition": "and",
"Field": null,
"Label": null,
"Not": false,
"Operator": null,
"Type": null,
"Value": null,
"Rules": [
{
"Condition": null,
"Field": "EmployeeID.ID1",
"Label": "ID1",
"Not": null,
"Operator": "equal",
"Type": "Number",
"Value": 4,
"Rules": null,
"RuleId": "querybuilder_group0_rule0"
},
{
"Condition": null,
"Field": "FirstName",
"Label": "First Name",
"Not": null,
"Operator": "endswith",
"Type": "String",
"Value": "d",
"Rules": null,
"RuleId": "querybuilder_group-1_rule0"
},
{
"Condition": "or",
"Field": null,
"Label": null,
"Not": null,
"Operator": null,
"Type": null,
"Value": null,
"Rules": [
{
"Condition": null,
"Field": "LastName.ID1",
"Label": "ID1",
"Not": null,
"Operator": "equal",
"Type": "Number",
"Value": 2,
"Rules": null,
"RuleId": "querybuilder_group1_rule1"
},
{
"Condition": null,
"Field": "Country",
"Label": "Country",
"Not": null,
"Operator": "equal",
"Type": "Object",
"Value": "England",
"Rules": null,
"RuleId": "querybuilder_group1_rule2"
}
],
"RuleId": null
},
{
"Condition": "or",
"Field": null,
"Label": null,
"Not": null,
"Operator": null,
"Type": null,
"Value": null,
"Rules": [
{
"Condition": null,
"Field": "UserActions.Click",
"Label": "Click",
"Not": null,
"Operator": "equal",
"Type": "Number",
"Value": 2,
"Rules": null,
"RuleId": "querybuilder_group1_rule3"
}
],
"RuleId": null
}
],
"RuleId": null
}
You can see the second group is named group1, the third group is also named group1
Hi Hakop,
Sorry for the delay. We have checked your reported query and prepared the sample based on your provided code snippet. But when we get rules for GetRules method of query builder and serialize the rule into json string, then deserialize the json string to RuleModel, we got null for all RuleId of rule shown as below.
Could you share the issue replicable sample or replicate issue in our sample. Based on that, we will check and provide you with a better solution quickly.
Regards,
YuvanShankar A
I neglected to supply the version i am using.
20.3.0.52
The bug is not happening on the version you are using. I downgraded your example and see the bug. Sorry about that. However it still happens in my app, not in the sample app.
{
"Condition": "and",
"Field": null,
"Label": null,
"Not": false,
"Operator": null,
"Type": null,
"Value": null,
"Rules": [
{
"Condition": "and",
"Field": "Contact Lists",
"Label": null,
"Not": null,
"Operator": null,
"Type": null,
"Value": null,
"Rules": [
{
"Condition": null,
"Field": "Contact Lists",
"Label": "Contact Lists",
"Not": null,
"Operator": "in",
"Type": "Number",
"Value": [
[]
],
"Rules": null,
"RuleId": "querybuilder_group1_rule0"
}
],
"RuleId": null
},
{
"Condition": "and",
"Field": "User Attributes",
"Label": null,
"Not": null,
"Operator": null,
"Type": null,
"Value": null,
"Rules": [
{
"Condition": null,
"Field": "User Attributes.2",
"Label": "MD5",
"Not": null,
"Operator": "startswith",
"Type": "String",
"Value": "1",
"Rules": null,
"RuleId": "querybuilder_group1_rule1"
},
{
"Condition": null,
"Field": "User Attributes.4",
"Label": "First Name",
"Not": null,
"Operator": "startswith",
"Type": "String",
"Value": "d",
"Rules": null,
"RuleId": "querybuilder_group1_rule2"
}
],
"RuleId": null
}
],
"RuleId": null
}
Sorry for the delay, Hakop.
We are glad to announce our weekly patch release (21.1.39) has been rolled out. We have included the fix for this "Query Builder GroupIds are not loaded correctly" issue in this release. So, we suggest you upgrade our Syncfusion packages to our latest version to resolve this issue on your end (21.1.39).