Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditionally show/hide column value in RecordTable #46

Open
alexmare93 opened this issue Jan 11, 2022 · 7 comments
Open

Conditionally show/hide column value in RecordTable #46

alexmare93 opened this issue Jan 11, 2022 · 7 comments

Comments

@alexmare93
Copy link

alexmare93 commented Jan 11, 2022

Hi @DigitalFlow,

How can I show/hide a column inside RecordTable based a value of that same fetchXml result?
I put an example:

I have a fetchXml which results 3 records. I have a RecordTable column called "Importo imponibile storno" that, if the field sap_transferline is set = Yes, I have to show the value of field sap_amount, else if field sap_transferline is set = No, always in the column "Importo imponibile storno" I have to show the value of field sap_deltaamount. I need that the column keeps having its label name.
This is currently my recordtable:

${{RecordTable ( Fetch ( "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'><entity name='sap_creditnoteproposaldetail'><attribute name='sap_creditnoteproposaldetailid'/><attribute name='sap_productdescription'/><attribute name='sap_invoicenumber'/><attribute name='sap_invoicedate'/><attribute name='sap_amount'/><attribute name='sap_deltaamount'/><attribute name='sap_transferline'/><attribute name='ownerid'/><order attribute='sap_name' descending='false'/><filter type='and'><condition attribute='sap_creditnoteproposalid' operator='eq' value='{1}'/></filter></entity></fetch>", Array(Value("regardingobjectid.sap_creditnoteproposalid"))), "sap_creditnoteproposal", [{ name: "sap_invoicenumber", label: "N. Fattura"}, { name: "sap_invoicedate", label: "Data Fattura", renderFunction: (record, column) => DateToString(Value(column, { explicitTarget: record }), { format: "dd/MM/yyyy" }) },{ name: "sap_productdesc", label: "Descrizione Prodotto"},{ name: "sap_amount", label: "Importo imponibile storno", renderFunction: (record, column) => Format(Value(column, {explicitTarget: record}), {format: "{0:0.00}"})}], true)}}

How could I resolve that?

Thank you,
Regards

@alexmare93
Copy link
Author

Hi @DigitalFlow ,

Could you please give me some advice?

Thank you,
Regards

@DigitalFlow
Copy link
Member

Hi @alexmare93,

That should be doable with a renderFunction which contains an if and checks for your column to modify the output.
You can write arbitrary XTL code inside the renderFunctions :)

Should look something like this:

${{RecordTable ( Fetch ( "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'><entity name='sap_creditnoteproposaldetail'><attribute name='sap_creditnoteproposaldetailid'/><attribute name='sap_productdescription'/><attribute name='sap_invoicenumber'/><attribute name='sap_invoicedate'/><attribute name='sap_amount'/><attribute name='sap_deltaamount'/><attribute name='sap_transferline'/><attribute name='ownerid'/><order attribute='sap_name' descending='false'/><filter type='and'><condition attribute='sap_creditnoteproposalid' operator='eq' value='{1}'/></filter></entity></fetch>", Array(Value("regardingobjectid.sap_creditnoteproposalid"))), "sap_creditnoteproposal", [{ name: "sap_invoicenumber", label: "N. Fattura"}, { name: "sap_invoicedate", label: "Data Fattura", renderFunction: (record, column) => DateToString(Value(column, { explicitTarget: record }), { format: "dd/MM/yyyy" }) },{ name: "sap_productdesc", label: "Descrizione Prodotto"},{ name: "sap_amount", label: "Importo imponibile storno", renderFunction: (record, column) => If(IsEqual(Value("sap_transferline", { explicitTarget: record }), true), Format(Value(column, {explicitTarget: record}), {format: "{0:0.00}"}), Format(Value("sap_deltaamount", {explicitTarget: record}), {format: "{0:0.00}"}))}], true)}}

Hope that helps.

Kind regards,
Florian

@DigitalFlow
Copy link
Member

Hi @alexmare93,

any news? I hope that my snippet should be able to solve your problem.

Kind regards,
Florian

@alexmare93
Copy link
Author

Hi @DigitalFlow ,

I'm sorry but I was on vacation. I will try what you suggest and I'll let you know.
Thank you very much,

Regards,
Alessandro

@Cris682
Copy link

Cris682 commented Feb 16, 2022

Hi @DigitalFlow , I'm a colleague of Alexmare93, we work on the same project.
Unfortunately the example provided does not work, the condition remains false even when the field is Y.
The sap_transferline field is an OptionSet with 3 possible values, and respective 9-digit keys.
I tried to pass the value "Y" once and then the key "804.060.000" but the condition always remains false. Surely I am wrong something in the condition on OptionSet. I tried searching the documentation but couldn't find any explanation for this specific case. Could you kindly help me?

Regards,
Cris.

@alexmare93
Copy link
Author

Hi @DigitalFlow ,

It seems we found the solution:

From this:

immagine

To this:

immagine

The missing part was the explicitTarget specified for the field/column.
We're going to make further test and, if everything is ok, we can close the thread.

Thank you,
Regards
Alessandro

@DigitalFlow
Copy link
Member

Hi Alessandro,

glad to hear that you found the cause :)

Yes sure, I'll await your test results.

Kind regards,
Florian

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants