Getting Data into editable grid

Hi,

I have written the following code where sampleData is a DataStore entity, but I am not getting any data in the front end:

rows: a!forEach( items: ri!sampleData,
expression: a!gridRowLayout(
contents: {
a!textField(
value: ri!sampleData.Account,
saveInto: fv!item.Account,
readOnly: true
),
a!textField(
value: fv!item.jan,
saveInto: fv!item.jan
),
a!textField(
value: fv!item.feb,
saveInto: fv!item.feb
),
a!textField(
value: fv!item.mar,
saveInto: fv!item.mar
)
}
)
),

But when I open the front end I see the following table:

What should I do so that the front end shows the data?

  Discussion posts and replies are publicly visible

Parents Reply Children
  • Hi pedro,

    I have created the rule input name sampleData which is a DataStore entity.

    Can rule Input store Datatypes? If yes, can you please elaborate a bit on what do you mean sampleDate as input? And how to proceed further for loading the data in the editable grid.

    And I am using readonly, because I want that users can't change some fields, but that is okay. I can remove that and work on it later.

  • 0
    Appian Employee
    in reply to Karanc

    Karen,

    Rule Inputs can be associated to several Appian Data Types including any CDT that you might have created. See the following link on how you can use a queryEntity with a cast to a particular CDT (https://docs.appian.com/suite/help/20.3/Query_Recipes.html#retrieve-the-data-for-all-fields).

    The code that you previously had for the readOnly field would probably generate an error or erroneous behavior. Please consider my previous observation

  • Hi Pedro,

    I have written an expression rule name Add_Budget and I am trying to refer to that for data extraction, still, I am not getting any rows in the front end. The modified code is belows:

    rows: a!forEach( items: ri!sampleData,
    expression: a!gridRowLayout(
    contents: {
    a!textField(
    value: rule!Add_budget().Account,
    saveInto: fv!item.Account,
    ),
    a!textField(
    value: rule!Add_budget().Jan,
    saveInto: fv!item.Jan
    ),
    a!textField(
    value: rule!Add_budget().Feb,
    saveInto: fv!item.Feb
    ),
    a!textField(
    value: rule!Add_budget().Mar,
    saveInto: fv!item.Mar
    )
    }
    )
    )

    Here the rule Add_budget is an express rule, I have even tried to use just the a!queryEntity to extract the data but nothing seems to work. 
     

    Can you please elaborate on the steps like what should be done?

  • 0
    Appian Employee
    in reply to Karanc

    Karan,

    I must admit that I am a bit confused on what you are trying to achieve. Some thoughts that I hope will help you:

    • If you want to call an expression rule, you need to add () after their name. So it will be rule!Add_budget().Feb assuming that Feb is a property of a Dictionary/CDT returned by the rule Add_budget. If you just do this simple replacement, you will find issues with your text Field (while changing a certain value)
    • If you are trying to have an editable grid with some pre-populated values from a Data Store Entity, consider this example https://docs.appian.com/suite/help/20.3/recipe-add-edit-and-remove-data-in-an-inline-editable-grid.html and replace the local variable employee for your CDT (fetch it from the DB and cast it to the respective CDT)
    • Assuming that the rule Add_budget is returning a dictionary with some pre-populated values, you can follow the same example mentioned above and construct your map or CDT by using that rule.

    Hope this helps,

    Pedro

  • Hi pedro,

    Sorry for the trouble.

    I read the documentation about appian adding, removing data from the editable grid. It seems like my initial code was quite similar to that, still, I am unable to fetch the data from the backend.

    Do I need to create a process model so that the rule Input Sample data can get data from the backend? Or just creating a rule input that contains a Data Store as its type is okay.

  • 0
    Appian Employee
    in reply to Karanc

    Karan,

    That depends on how and where you want to use that interface. I suggest you passing as an input the type (CDT) that will be used in the grid. Once you decide on that, you just need to ensure that you're passing the correct type everywhere you use that interface. 

    Assuming that "get data from the backend" means getting data from a database, you can create a rule input that will retrieve the data that you want (using queryEntity), cast that data to the proper CDT and then you can reference that rule where you call your interface. Something like this:

    rule!interface(sampleData:rule!GetDataForInterface())

  • Pedro,

    I am able to extract data from the rule input with the command rule!Add_budget().Jan[0] (Here Add_budget is an expression rule), but how to show the same in the editable grid. And also I can't use the index 1 for every row.

    I can't figure out why the code is not working in the editable grid, while I am able to extract the data.

  • 0
    Appian Employee
    in reply to Karanc

    Karan,

    Please shed some more light on what you're trying to do. Is it to change a set of items and update them in the database? Also please share your rules definitions and code

  • I want to extract the data from the database in an editable grid so that I add data or update the existing data.

    Steps taken for this:

    1. Created a DataType, which corresponds to the target table in the database

    2. Added DataType in DataStore

    3. Created a constant of the DataType

    4. In the interface created a rule input (sampleData) which is DataStore

    5. Create an editable grid which shows the data (Stuck Here)  

    Experiments:

    1. Try to create expression rule name (Add_budget)

    2. Try creating a process model

    Hopefully this helps

  • 0
    Appian Employee
    in reply to Karanc

    Karan, you're trying to edit items from a "DataType" type. Taking that into consideration, your interface's rule input should be of the "DataType" type and not and not a Data Store Entity. See more of these concepts in the following link (https://docs.appian.com/suite/help/20.3/Data_Stores.html)

    Once you have the CDT that you created as the type of your rule input, you will need to test that your interface is working, i.e:

    1. Receives a list of your DataType (you can use a queryEntity on your test)
    2. After updates on the grid, your rule input contains the updated values (check the rule inputs section of your interface designer).

    Once you do that, you're set for success and just need to figure out the where you will use that interface. You can use by itself or with a process model. Both approaches allow to write to the data store entity (docs.appian.com/.../Write_to_Data_Store_Entity_Smart_Service.html)