Question

Smartforms List View List Item State


Hi all

 

I have a question regarding k2 smartforms list view that I need your help with. Lets say I have a list view and I execute a list method which reads three records and lists them on the list view. Now, I would like to write whatever is in the list view currently to another table. When I use the 'Execute acarete method for all items that are in a state "Added". The records dont get added to the new table beacsue the list view does not recognise the three records as added. Is there a solution to this.

 

Also what is the purpose and how does the list refresh method work.

 

Thanks


22 replies

Hi,


 


Are you transfer the data from List View 1 which is loaded from let's say SmartObject 1 to SmartObject 2/List View 2?


 


Regards,


 

Hi,


 


Just a quick note: remember to save the record after you have added it, so that you're able to view it when you excute. 


 


Regards


Nelly

Thanks for your replies. Im not sure what you guys mean by transferring data from smartobject 1 to smarobject two. I have explained what I would like to achieve below.


Database Table One

pen           78

pencil       34

paper       33

 

Database Table Two

Empty

 

 

List View 1

 

Item       |      Price

pen                 78

pencil             78

 

Populate list view 1 by calling list method that looks into db table one and lists all items. make some changes to list view 1. On save button click, I would like to take all data from list view one and write it to db table two with all changes made to the two items in list view 1. 

 

Thanks.

 

 

So are you using Composite SmartObjects?

Its all singular tables and singular smartobjects.

Hi,


 


Have you tried creating a rule that will execute the create method for the first as well as the second SmartObject? I know that transfering records from table controls are quite tricky.


 


Regards,

I dont think I need to eecute the create method for the first table beacuse it is where the data is coming from so it already contains the data. I just need to execute the create methd for the second table but the list view deosnt seem torecognise the threee records as being "added".

 

Thanks

 

Badge +5

Hi,

 

If you want to write the entries from your list view to another list you will need to use the the states for the items.

Use the "Execute a SmartObject method for items that have been changed" action.

Added will only be triggered for new items added to the list, Changed will only be for items which have been changed and unchanged is for the ones that haven't been changed.

You will then need to configure a rule on the Added, Changed and Unchanged events that will call the Create method of the other smartobject and that should save all the items to the other SmartObject.

 

Hope this helps!

JohanL

 

 

 

Hi,


 


Yes I agree with Johan's previous response. If you give it a try please keep us posted on the results.


 


Regards.

Hi all,

 

I am using the "Added" state, but the list view does not recognise the list item as being added. It only recognises added items if you click the and add a record. I would like to explain my scenerio again if that will help.

 

I have two database tables. Table A and Table B.

 

Tables A fields

Name

Address

Telephone

 

Table B fields

Name

Address

Telephone

Status

 

I have only one smartobject method which is lets say "Person".

 

Person Smartobject has the followig methods.

 

Create --- maps to Table B Create

Delete --- maps to Table B Delete

Update --- maps to Table B Update

List Table B --- maps to Table B List

List Table A --- maps to Tale A List

 

So Lets say Table B is empty and Table A has one record.

I have a list view based on the Person Smartobject.

 

I would call the list method "List Table A" which will list one record from Table A onto the list view.

 

Now When I click a button on the view (form). I execute a "Execute "Create" method of Person smartobject for all items that have been "Added" method. This is where its failing because the rule does not recognise the item that was added from the "List Table A" method as being added.

 

 

 

 

Badge +7

Hi S0m3one


 


I have something that you can test depending on what you want to achieve, I made a few possible solutions. Please have a look at the relevant one, test it and let me know if it worked to your satisfaction.


 


Option 1:


If you want to get the data from smartobject (1) to populate list view (1) where you can edit the data and then save the data to SmartObject (2) without updating smartObject (1).


 


Then do the following:


In the view navigate and open to the Save Button Rule in Edit mode, now remove the "Create" and "Delete" rules and replace the "Save"rule (Execute the save rule for all items that has been Removed (Configured) ) with (Execute a SmartObject method) and configure the smartobject method with the following:


1. Select smartobject that you want to save to


2. Select save option.


3. Configure rule's input mapping by dragging the views text boxes to the smartobject that you want to save to


 


Option 2:


If you want to get the data from smartobject (1) to populate list view (1) where you can edit the data and then save the data to SmartObject (2) and smartObject (1).


 


Then do the following:


Do Option 1 and add another (Execute a SmartObject method) and set it up the same as the prevoius but with the other SmartObject being selected.


 


 

Sorry Raymond, I dont understand why you would execute the "removed" state method. If I removed nothing from the list view then that method is not going to be executed.

Badge +5

Hi,

 

As you configured the Added state, add two more states with exactly the same rules.

One for Changed and the other for Unchanged.

Then it will create them all.

 

Let me know if this works.

 

Regards,

JohanL

Badge +7

Hi S0m3one


 


I apologize this was a typing mistake. What I meant to say was:


Instead of using (Execute the Save rule for all items that has been Changed) rather use (Execute a SmartObject method) for each of the smartobject that you want the data to be saved to. 


 

Thanks for your replies. I have tried using the states and it still doesn't recognise items that have been listed from Table A as being added/changed or unchanged. It only recognises items that have been added to it using add/edit/delete buttons on the lsitview as being added changed or deleted.

Thanks

I've included the ID column of my database table to my listview and gave it an expression which just contains the value '0'. This will flag the rows added by the List method as changed and it's possible to use the 'Execute the ... method for all items that have been changed'.

 

This is what I'm currently using in order to re-use older form data for new forms. I load the old data and flag them as changed by doing the above and finally store them in my database for the new form.

Please could you explain that in more detail. What do you mean my setting an expression on the ID and make the list view recognise it as a change. 

 

Thank

I've included an ID column to my listview which contains the ID of the records in my database. While editing the listview you can click the column and set an expression in the properties. You can set the expression to just have a value of '0'. This will set the ID to 0 when you are using the List method so that each row that gets added will be flagged as changed.

I I understand this correctly, you must at least click on an item to register a change. There may be occasions where none of the items are changed/cicked on.

 

By using an expression like in my example it will automatically change the ID of each row obtained by the List method to 0. This will count as a change and the user isn't required to edit anything.

Hi

 

I still cannot get it to do what you were saying. So I have a method that gets a list of records and populates the listview. Now I have set tan expression on one of the controls in the list view on the add/edit section to to get value from an expression and the expression basically return a 0 at all time. This is not working so where should i set the expression and how. 

 

Thanks

Sorry. Firstly, my expression was wrong and secondly it should be placed in the display area instead of the add/edit area. Thanks.

Reply