Hi there, I'm having a problem in automatically creating multiple records of Object_B, whose fields' values are determined by one particular newly created record of Object_A.
I can achieve all this on the browse side by clicking a customized button (not the Rollbase 'SAVE' button). The issue of this manner is that the relationship between multiple Object_B's record cannot be established with that particular Object_A record. This is because the Object_A record has not been written into databse yet.
Now, I'd like to use triggers on the Object_A side to automatically create Object_B's records after the Object_A record has been created. By doing this, the Object_A record is actually in the database, thus I could attach relationships.
Questions are:
1. Since my case is converting one object to many objects, I don't if the Data Conversion Map still works?
If yes, please tell me how to do it? I am only aware of how to convert one object to another.
2. I have uncertain number of input fields to be fulfilled on the "New Object_A" page, each of those fields is actually going to be one record of Object_B. Since the number of the input fields are dynamic, so I cannot define these fields in the Object Definition of Object A. When user clicks 'SAVE', I need the input value of all these <input> fields to be passed to a trigger in order to create records of Object_B.
How can I pass those value of input fields to a trigger? Now I've saved them in a JS Map.
I am wondering if it is possible to use HTTP POST, but I don't know how to do it.
If this could work, what type of trigger should I use on Object_A? Create New Record or Object Script?
Many many thanks, hope everyone has a nice weekend!!
Set up a hidden defined field and use client side JS to store the dynamic fields and values using standard HTTP GET format (name/value pairs). Then retrieve and parse those values in the trigger.
I'm not sure why you want to would use an HTTP POST in a trigger to add new Rollbase records. The Object Scripts are intended to do that within the trigger. See the OBJECT SCRIPT API section in Rollbase in Action (starting on page 182) and specifically the rbv_api.createRecord() method on page 185 for how to add new records in a trigger.
If you're destined to use HTTP POST (which is really for external systems), then you need to establish an Integration Link field in Object A to define the destination and then a sequence of triggers to send the REST call and another to process the results. See Chapter 6. Server-side Code: Templates, Formulas and the Rollbase Query API for more information on that or page 63 for a definition of an Integration Link.
If you want to create several Object_B records when an Object_A is created, you can define a trigger of type "Object Script" that lets you run some JavaScript code. Inside this, you can call rbv_api.createRecord() as many times as you want.
Hi Cohezive, thanks for the responds.
I've used Object Script Trigger and the rbv_api.createRecord() method for other task already. They could work only if the fields are predefined in the parent object definition.
For the current issue, all field and value pairs are generated on the fly, they are just on the browse side at the moment
I don't know how to retrieve the data within the trigger.
Set up a hidden defined field and use client side JS to store the dynamic fields and values using standard HTTP GET format (name/value pairs). Then retrieve and parse those values in the trigger.