Skip to main content

Report Detail Format - Script

Comments

9 comments

  • Permanently deleted user

    Hi Walter,

    You can test the fields value, see below.

     

    bool backColor = true;

     

    string greenFieldName = "status";

     

    string greenFieldValue = "Signed";

     

    public void detail_Format()

     

    {

     

        if (backColor)

     

        {

     

            rpt.Sections["detail"].BackColor =System.Drawing.Color.Silver;

     

        }

     

        else

     

        {

     

             rpt.Sections["detail"].BackColor = System.Drawing.Color.Transparent;

     

        }

     

        

     

        backColor=!backColor;

     

        

     

        //Check for the field value and change the color to Greenif it matches.

     

         string fieldValue = rpt.Fields[greenFieldName].Value as string;

     

        if (fieldValue == greenFieldValue )

     

        {

     

            rpt.Sections["detail"].BackColor =System.Drawing.Color.Green;

     

        }

     

    }

     

     
    0
  • Permanently deleted user

    Mark,

    Thanks for your reply. Although alittle closer, I still get an error on line 25....Error = Identifier expected

     

    bool backColor = true;

     

     string greenFieldName = "site_status";

     

     string greenFieldValue = "Signed";

     

     

     

    public void detail_Format()

     

     {

     

         if (backColor)

     

         {

     

             rpt.Sections["detail"].BackColor =System.Drawing.Color.Silver;

     

         }

     

         else

     

         {

     

              rpt.Sections["detail"].BackColor = System.Drawing.Color.Transparent;

     

         }

     

        

     

         backColor=!backColor;

     

        

     

         //Check for the field value and change the color to Greenif it matches.

     

          string fieldValue = rpt.Fields[site_status].Value as string;

     

         if (fieldValue == greenFieldValue )

     

         {

     

             rpt.Sections["detail"].BackColor =System.Drawing.Color.Green;

     

         }

     

     }

     

    Walter

    0
  • Permanently deleted user

    The field name is in the variable 'greenFieldName'.

    change this line: string fieldValue = rpt.Fields[site_status].Value as string;

    to: string fieldValue = rpt.Fields[greenFieldName ].Value as string;

     

    0
  • Permanently deleted user

    Mark,

    I still get an error "Exception has been thrown by the target of an invocation"

    bool backColor = true;

     

     string greenFieldName = "site_status";

     

     string greenFieldValue = "Signed";

     

     

     

    public void detail_Format()

     

     {

     

         if (backColor)

     

         {

     

             rpt.Sections["detail"].BackColor =System.Drawing.Color.Silver;

     

         }

     

         else

     

         {

     

              rpt.Sections["detail"].BackColor = System.Drawing.Color.Transparent;

     

         }

     

        

     

         backColor=!backColor;

     

        

     

          //Check for the field value and change the color to Greenif it matches.

     

          string fieldValue = rpt.Fields[greenFieldName].Value as string;

     

         if (fieldValue == greenFieldValue )

     

         {

     

             rpt.Sections["detail"].BackColor =System.Drawing.Color.Green;

     

         }

     

     }
    0
  • Permanently deleted user

    Walter,

    debugging scripting in report designer is a challenge.

    Are you able to email your .rpx file to me. I can have a quick look. mhoyland@ssc.nsw.gov.au

    0
  • Permanently deleted user

    Mark,

    Did you receive the email I sent you?

    Appreciate your help....Walter

    0
  • Permanently deleted user

    Walter,

    I got your email and replied to it yesterday with some slight changes in the report. Looks like it has not made it to you.  I just sent another one to you without attachments to see if gets there. I will update this post with the changes, when I get a chance.

    0
  • Martin Simonsen Bjørkenes
    Hi Mark

     

    I have run into the same issue when trying to toggle the background color based on an input value. I get "Exception has been thrown by the target of an invocation". What kind of changes did you do to the report to make it work? 

     

    Martin

     

     
    0
  • Permanently deleted user
    Hi All,

     

    I am having the same problem. I cannot figure out how to change the backgroud colors for the text (between yellow/transparent) if the status of my field is unsafe/safe. If anyone has working script and could share it I would very much appreciate it.

     

    Thanks,

     

    Nataliya
    0

Please sign in to leave a comment.