Writing logic for a on click button

Hi Everyone,

Need to write the logic for accept button. On click accept it should store the data of the drop down menu, the comments input section and the details of the table.


Service studio Screenshot -


Ui Screenshot



Hi Saif,

You should just put a create/update statement behind the Accept button that inserts (or updates if that is possible) a row in the table that you use for storing the records (this would also be the source of the table in the UI).

I assume that the data in the dropdown has its own source and is connected to the other table using a foreign key. If so, you should be able to just pass all the values to the server side of your application and do the create statement. 

 After that action do a refresh of the data aggregate and the newly created record will be visible!

Hi Max,

Thank you for Swift reply. Could you assist me with steps since i am a beginner with outsystems.

Hi Saif,

Regarding the reply you made to Pallavi, the source data you have is coming from an external DB using API, right? Are these also the values that populate the dropdown?
Do you need to make changes to this data by adding whether it got approved or not and storing the comment or are you saving the approvals locally?

In case of the latter, do the following:

- Create a server action in the core of your application (CreateUpdateRecommandation for instance).
- Add input parameters of type: Recommandation Id (coming from the API), Dropdown value Id (if needed) and Comment (text).You also chose to expose the entire table you are saving to and using that as input parameter (set the type to the table).

In the server action do a assign statement where you assign above values to a variable of type RecommandationTable and createUpdate action after that. 


If you need to make changes the data provided by the API you can do something similar but with a POST or PUT API type. 


The list in the drop down are reasons for accepting or rejecting and are independantly imported using excel.

The table data is brought using Api

Consider an auditor who wants to approve or reject based on the parametres they see inside the table.

Need functionality to store the decision of the auditor along with input variable for comments.

TestModuleV2_.oml

Okay. I would change the design a bit first and put the dropdown, comment section and buttons in the table row itself. This will be easier later on when you need the Id (or some other identifier) of the data in the table (API Data) to store it locally. 

If you are not able to do this for whatever reason, you will need to make some logic that can store an identifier locally by clicking on the record in the table. You will need this anyway to make a distinction between the rows and save the correct reason and comment per row. 

The logic behind your accept or reject buttons still need the same inputs as I described earlier meaning an identifier of the API data, the dropdown Id, the comment and whether it got accepted or not (a boolean value). If you pass this to the server and do a create or update statement for you local entity it will be saved.

Try to use this, you add some test data to the API table (this is local but you should replace it with your real API data later on). 


DataStoreExample.oap

Hi Saif,

May this oml helps you.

First, add the data in the  'Address' Database manually and you will get your functionality.


Thanks,

Pallavi

Createdemo.oml

Hi Pallavi,
Thank you for your efforts. but the data i have in the table is already received through API.

Consider an example -

User opens the screen, it has the data already present.
User can either approve or reject based on the options in Drop down and can also add comments.
But he cannot change the data. 


Try this 

Please insert some records for name columns in Operator DB and (Accept, Reject status)records in Status DB .

And try at browser.

Thanks

Createdemo.oml

Hi Pallavi.

I am getting this error when i tried inserting the data in operator data 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.