Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
ProjectWise
  • Product Communities
ProjectWise
ProjectWise Design Integration Forum Update an attribute based on two different check boxes
    • Sign In

    • State Not Answered
    • Replies 2 replies
    • Subscribers 61 subscribers
    • Views 570 views
    • Users 0 members are here

    Update an attribute based on two different check boxes

    Aitor de la Fuente
    Offline Aitor de la Fuente over 3 years ago

    Hi all!

    I am trying to configure in PW an attribute that should display the username if one checkbox is checked, but the text N/R if another is checkbox is checked. If none is checked, the attribute remains empty.


    My attributes are:

    CHK1 (integer, allow nulls)
    CHK2 (integer, allow nulls)
    Approval_By (char, allow nulls)

    The Approval_By attribute is updated when CHK1 or CHK2 are updated. If CHK1 is selected, the field must return N/R and if the CHK2 is selected the field must return the username.

    I have tryed with the following value (on PW Administrator):

    SELECT CASE WHEN '$EDIT#CHK1$' = 1 THEN 'N/R' ELSE '$USER.NAME$' END

    However, I don't know what I'm doing wrong, my programming knowledge is quite limited, but PW Explorer gets stuck and gives any errors related to the Approval_By attribute, even if I don't do anything related to it.

    I would be very grateful if someone guides me a little on this topic.

    Thanks in advance.

    • Sign in to reply
    • Cancel
    Parents
    • Scott Turner
      0 Offline Scott Turner Tue, Apr 7 2020 6:17 PM

      Hi Aitor,
      One thing I'd do here is to eliminate one of the CHK attributes, since having two will make it harder to accurately determine the correct value for Approval_By.
      The code you show above isn't quite what you'd need here.  The CASE expression would be used to look at several potential outcomes, where you have only two so IF should be all you'd need:  IF $EDIT#CHK1$ = 1 SELECT 'USER.NAME' ELSE SELECT 'N/R'.

      The value tested for could be zero or one, depending on when you want N/R or the user name to be returned.  Having a default value for Approval_By of N/R would also be good, since this would add consistency to what the user sees.  The query here is written assuming you did this.
      Note that I've also removed the quotes from $EDIT#CHK1$.  The reason for this is that if quoted, SQL will treat it as text but you have defined this as an integer so don't quote it.  Not a major issue, just a bit more accurate.

      HTH

      Scott

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Aitor de la Fuente
      0 Offline Aitor de la Fuente Wed, Apr 8 2020 1:00 PM in reply to Scott Turner

      Thanks a lot Scott, It has been a great help to me

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    Reply
    • Aitor de la Fuente
      0 Offline Aitor de la Fuente Wed, Apr 8 2020 1:00 PM in reply to Scott Turner

      Thanks a lot Scott, It has been a great help to me

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    Children
    No Data

    Communities
    • Home
    • Getting Started
    • Community Central
    • Products
    • Support
    • Secure File Upload
    • Feedback
    Support and Services
    • Home
    • Product Support
    • Downloads
    • Subscription Services Portal
    Training and Learning
    • Home
    • About Bentley Institute
    • My Learning History
    • Reference Books
    Social Media
    •    LinkedIn
    •    Facebook
    •    Twitter
    •    YouTube
    •    RSS Feed
    •    Email

    © 2023 Bentley Systems, Incorporated  |  Contact Us  |  Privacy |  Terms of Use  |  Cookies