I am trying to create a function that allows me to create a JSON by pressing a button. The problem I am having is that one of the fields must be an array and it depends on what is selected, or not, in 2 ComboBox. Everything works perfectly when I create the If with 3 scenarios:
This is the function that I have created for this case:
Set(JSONItems;JSON(ClearCollect(Items;
ForAll(Gallery1_1.AllItems;
{
TAXES:
If(
And(!IsBlank(ComboBox4_1.Selected.id);!IsBlank(ComboBox3_1.Selected.id));
Table(
{
id: ComboBox4_1.Selected.id
};
{
id: ComboBox3_1.Selected.id
}
);
And(!IsBlank(ComboBox4_1.Selected.id);IsBlank(ComboBox3_1.Selected.id));
Table(
{
id: ComboBox4_1.Selected.id
}
);
And(IsBlank(ComboBox4_1.Selected.id);!IsBlank(ComboBox3_1.Selected.id));
Table(
{
id: ComboBox3_1.Selected.id
}
)
)
}
)
);IndentFour))
And this is the result:
Note that in the last case it returns a null which is not valid for an array. This is the case where nothing is selected in the controls and it is not contemplated in the function.
The problem arises when I add a 4 scenario, when both ComboBox have nothing selected. At this point the result is that no matter what scenario is presented, the resulting array does not have any records in it.
This is the function that I have created for this case:
Set(JSONItems;JSON(ClearCollect(Items;
ForAll(Gallery1_1.AllItems;
{
TAXES:
If(
And(!IsBlank(ComboBox4_1.Selected.id);!IsBlank(ComboBox3_1.Selected.id));
Table(
{
id: ComboBox4_1.Selected.id
};
{
id: ComboBox3_1.Selected.id
}
);
And(!IsBlank(ComboBox4_1.Selected.id);IsBlank(ComboBox3_1.Selected.id));
Table(
{
id: ComboBox4_1.Selected.id
}
);
And(IsBlank(ComboBox4_1.Selected.id);!IsBlank(ComboBox3_1.Selected.id));
Table(
{
id: ComboBox3_1.Selected.id
}
);
And(IsBlank(ComboBox4_1.Selected.id);IsBlank(ComboBox3_1.Selected.id));
Table()
)
}
)
);IndentFour))
And this is the result:
Note that in the cases where previously there was a record, now there is nothing.
I appreciate any help you can give me, I have been fighting with this for 2 days and I am losing the battle.
Solved! Go to Solution.
Thank you very much for your answer. The only detail with your proposal is that I cannot send any data in that array because whatever I send it will look for it in the database. Likewise, I update the post commenting that I managed to solve the problem by doing the following:
1.- Creating a collection with only one records and with the correct columns and data types.
2.- Use the Clear () function to delete the record and leave the collection with only the columns.
3.- In the event that both ComboBoxes do not have anything selected, do not use a blank table if not the collection.
Hi @robertopolo
Looks like a bug in the JSON conversion. A workaround you can try this to have value 0 (Not sure if this is acceptable)
Set(JSONItems;JSON(ClearCollect(Items;
ForAll(Gallery1_1.AllItems;
{
TAXES:
If(
And(!IsBlank(ComboBox4_1.Selected.id);!IsBlank(ComboBox3_1.Selected.id));
Table(
{
id: ComboBox4_1.Selected.id
};
{
id: ComboBox3_1.Selected.id
}
);
And(!IsBlank(ComboBox4_1.Selected.id);IsBlank(ComboBox3_1.Selected.id));
Table(
{
id: ComboBox4_1.Selected.id
}
);
And(IsBlank(ComboBox4_1.Selected.id);!IsBlank(ComboBox3_1.Selected.id));
Table(
{
id: ComboBox3_1.Selected.id
}
);
Table({id: 0}) // Or Table({id: Text(0)})
)
}
)
);IndentFour))
Note: No need to specify 4th condition
Either Table({id: 0}) // Or Table({id: Text(0)})
Thank you very much for your answer. The only detail with your proposal is that I cannot send any data in that array because whatever I send it will look for it in the database. Likewise, I update the post commenting that I managed to solve the problem by doing the following:
1.- Creating a collection with only one records and with the correct columns and data types.
2.- Use the Clear () function to delete the record and leave the collection with only the columns.
3.- In the event that both ComboBoxes do not have anything selected, do not use a blank table if not the collection.
User | Count |
---|---|
260 | |
116 | |
99 | |
48 | |
41 |