Conditional rendering from script

Posted by: peter.schmucki on 30 January 2019, 6:14 am EST

    • Post Options:
    • Link

    Posted 30 January 2019, 6:14 am EST

    I have a SectionReport in which I’d like to render conditionally. Yet I face two major problems:

    How do I access a Field in the Report that I already set?

    How do I access data from the Dataset I could drag in like @ClientName, but in code?

    We’re currently running VB.NET Scripts, but also responses in C# are very welcome.

    What I tried so far:

    public void ActiveReport_ReportStart() {
    	rpt.Fields["fmlFormel_Text_Rekapitulation"].Value = "Hallo Welt!";
    }
    

    We’re currently running VB.NET Scripts, but also responses in C# are very welcome.We’re currently running VB.NET Scripts, but also responses in C# are very welcome.

    What I tried so far:What I tried so far:

    public void ActiveReport_ReportStart() {
    	rpt.Fields["Formel_Text_Rekapitulation1"].Value = "Hallo Welt!";
    }
    

    Yet I got a null pointer exception. The name is from Draft (Name) in the property dialog.

  • Posted 30 January 2019, 10:13 am EST

    Hello Peter,

    How do I access a Field in the Report that I already set?

    Could you please explain your use case so that I will help you accordingly. You cannot change the value of the fields at runtime. However, you can change the value of the report item(Like TextBox) that are bind with fields according to some condition in the report script.

    How do I access data from the Dataset I could drag in like @ClientName, but in code?

    From this, I understand that you want to bind the report item with fields at the runtime. If my understanding is correct then you can directly set the field name to “DataField” property of report item in ReportStart Event. Please refer to the attached report.

    If my understanding is wrong, then could you please explain.

    Thanks.

    rpt_DataSet.zip

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels