Interface not automatically populating form fields

I have created a form interface that is intended for a user to type in or scan in a barcode number. The interface should then query the connected external database, and automatically populate the remaining form fields with the barcode number's data record.

The user will then type in any extra comments he may have and attach any photos if he desires. Once the form is completely filled out, the user clicks the "Submit Record" which will then save the data record into a local datastore entity.

I posted my first question last week and was advised to use a query entity. The problem I'm facing now is that once the barcode is typed into the barcode field, the remaining fields are not auto populating as intended. And SAIL doesn't show any errors, just nothing happens.

Can someone please take a look at my interface definition and see what I could be doing wrong. Thanks!

PDF

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Well first off, you're defining the value of the barcode field with "ri!getTireRecord.object_name", but as far as I can see you're never saving any value into ri!getTireRecord, so anything you enter there will apparently blank out (or revert to its default value).  So I'm not sure which one of these you need, but you need to straighten out your data a bit as this is probably one of the main reasons you're not seeing what you expect.

    As far as your query for saving data into ri!addAnomalyRecord - all I can suggest is that you need to test your a!queryEntity statement in an external expression rule and make sure it works as expected for a given input.  In general I suggest always making query entities in an external expression rule (for this reason among many others), at least when there's any chance a similar query will be needed anywhere else in your system.  As a side note, I see that your reference to cons!3FS_V6_GetTireRecord is in single-quotes; i'm not sure why you did that but it's definitely not necessary (though i just learned that it apparently works, for some reason).

  • Mike,

    Sorry if I'm not understanding. I'm still learning Appian. First, the "ri!getTireRecord.object_name" is the CDT of the data source where I'm trying to pull the record from. Just wanted to restate this to clear any confusion.

    I have made the changes you suggested and have instead defined the value of the barcode field with "ri!addAnomalyRecord.object_name" and then saved the values to ri!addAnomalyRecord. But when I test the form, I am now getting this weird error about "Cannot apply operator [EQUALS] to [object_name] when comparing value....."


    eRecord.object_name
  • 0
    Certified Lead Developer
    in reply to Pauly

    I will probably have more suggestions for how to straighten up your form data, but the error message relates strictly to the query as far as I can tell.

    Therefore, at this point the only path forward I can think of is to take your whole a!queryEntity expression and test it in a new Expression Rule editor (the only change you'll need to make is replacing "save!value" with a string representing the barcode number you're testing).  If it works fine there then let me know and we can keep troubleshooting your form, and if you get the same error there, the first thing I'd suggest is checking your data types (particularly the type of "object_name" within your CDT and database table).

    And, no worries about being new - we've all been there and it takes some time to learn... and the Appian/SAIL expression language, as programming languages go, takes a bit of adjustment in how you think about things, compared to traditional languages.

  • 0
    Certified Lead Developer
    in reply to Pauly

    I was thinking about this some more since last night and i believe you would gain a bit more clarity in your data by shifting the Barcode Value to a local variable, instead of your current method where you set it briefly but then query a new value on top of it.

    Please see the attached example and let me know if you still have any questions and/or if it helps at all:

    a!localVariables(
      local!barcodeValue,
      
      a!formLayout(
        contents: {
          a!barcodeField(
            label: "Barcode",
            value: local!barcodeValue,
            saveInto: {
              local!barcodeValue,
              
              /* query Anomaly by entered barcode value */
              a!save(
                ri!addAnomalyRecord,
                if(
                  isnull(local!barcodeValue),
                  {},
                  rule!3FS_myAnomalyQueryEntityRule(
                    barCodeValue: local!barcodeValue
                  )
                )
              ),
              
              /* optionally, you can also query Tire Record by entered barcode value */
              a!save(
                ri!getTireRecord,
                if(
                  isnull(local!barcodeValue),
                  {},
                  rule!3FS_myTireRecordQueryEntityRule(
                    barCodeValue: local!barcodeValue
                  )
                )
              )
            }
          )
        }
      )
    )

    Note that I've invented (obv fake) expression rule names here to contain your a!queryEntity statements for both Anomaly as well as Tire Records.  You can replace these with on-form queries if needed for testing purposes of course.

Reply
  • 0
    Certified Lead Developer
    in reply to Pauly

    I was thinking about this some more since last night and i believe you would gain a bit more clarity in your data by shifting the Barcode Value to a local variable, instead of your current method where you set it briefly but then query a new value on top of it.

    Please see the attached example and let me know if you still have any questions and/or if it helps at all:

    a!localVariables(
      local!barcodeValue,
      
      a!formLayout(
        contents: {
          a!barcodeField(
            label: "Barcode",
            value: local!barcodeValue,
            saveInto: {
              local!barcodeValue,
              
              /* query Anomaly by entered barcode value */
              a!save(
                ri!addAnomalyRecord,
                if(
                  isnull(local!barcodeValue),
                  {},
                  rule!3FS_myAnomalyQueryEntityRule(
                    barCodeValue: local!barcodeValue
                  )
                )
              ),
              
              /* optionally, you can also query Tire Record by entered barcode value */
              a!save(
                ri!getTireRecord,
                if(
                  isnull(local!barcodeValue),
                  {},
                  rule!3FS_myTireRecordQueryEntityRule(
                    barCodeValue: local!barcodeValue
                  )
                )
              )
            }
          )
        }
      )
    )

    Note that I've invented (obv fake) expression rule names here to contain your a!queryEntity statements for both Anomaly as well as Tire Records.  You can replace these with on-form queries if needed for testing purposes of course.

Children
No Data