Can default values be set for the insert API?
There are several ways to set default values for the content added by the insert API.
Please implement the desired method by referring to the methods for the frontend, preprocessing, and triggers.
In this FAQ, we assume the code for the Member::insert endpoint.
Setting default values for Member::insert
Implementing on the frontend
For example, let's say the "Don't subscribe to notifications" for a member is registered with the default value (unchecked state) by default.
When sending a request from the frontend, if you implement it to include "email_send_ng_flg": false
in the request, you can register a member with the "Don't subscribe to notifications" unchecked.
Add "email_send_ng_flg": false
to the request without showing it to the user, as shown below.
loading...
Adding preprocessing
For example, if a numeric value is set for an extended item of a member, it will be registered as blank if no value is specified in the request via the API.
If there are multiple extended items of numeric value type and you want to set 0 as the default value for all of them, you can write a custom preprocessing and set it as a preprocessing step.
By setting it in Pre-processing, you can set default values for each endpoint.
loading...
Setting a Trigger
You can also set default values for multiple numeric value type extended items using a trigger.
The trigger uses "Before Member Registration".
The variable name used in custom processing is slightly different from the pre-processing pattern.
By setting it with a trigger, you can set default values for all members registered through the API.
loading...
Related Documents
Support
If you have any other questions, please contact us or check out Our Slack Community.