sul-dlss / folio-tasks

Migration and data-loading tasks for FOLIO
MIT License
2 stars 1 forks source link

New Custom Fields Rake Task #137

Closed jermnelson closed 1 year ago

jermnelson commented 1 year ago

Currently the step to add custom user fields requires manually adding these fields via FOLIO UI. Observing the sequence from the UI developer tools, a new rake task could do the following:

  1. Make a PUT to Okapi /custom-fields endpoint with the following header variable: x-okapi-module-id: mod-users-19.0.0 with the following JSON payload:
{
    "customFields": [
        {
            "entityType": "user",
            "helpText": "",
            "id": null,
            "name": "Affiliation",
            "required": false,
            "type": "TEXTBOX_SHORT",
            "visible": true
        },
        {
            "entityType": "user",
            "helpText": "",
            "id": null,
            "name": "SecondAffiliation",
            "required": false,
            "type": "TEXTBOX_SHORT",
            "visible": true
        },
        {
            "entityType": "user",
            "helpText": "",
            "id": null,
            "name": "Usergroup",
            "required": false,
            "selectField": {
                "multiSelect": false,
                "options": {
                    "values": [
                        {
                            "default": false,
                            "id": "opt_1",
                            "value": "Acting Instructor"
                        },
                        {
                            "id": "opt_2",
                            "value": "Clinical Instructor"
                        },
                        {
                            "id": "opt_3",
                            "value": "Consulting Instructor"
                        },
                        {
                            "default": false,
                            "id": "opt_0",
                            "value": "Instructor"
                        },
                        {
                            "id": "opt_4",
                            "value": "Lecturer"
                        }
                    ]
                }
            },
            "type": "SINGLE_SELECT_DROPDOWN",
            "visible": true
        },
        {
            "entityType": "user",
            "helpText": "",
            "id": null,
            "name": "MobileId",
            "required": false,
            "type": "TEXTBOX_SHORT",
            "visible": true
        },
        {
            "entityType": "user",
            "helpText": "",
            "id": null,
            "name": "ProximityChipId",
            "required": false,
            "type": "TEXTBOX_SHORT",
            "visible": true
        }
    ]
}
  1. Next, make a POST to /configurations/entries with the following JSON payload
{"module":"USERS","configName":"custom_fields_label","value":"Custom fields"}
shelleydoljack commented 1 year ago

I'm currently trying a PUT to /custom-fields on folio-dev with a custom field called "TestCustomField" and it is taking over 5 minutes to complete the request. I can refresh folio-dev and see the new field, but I still have not received a response from okapi after the fields were created. Would the rake task just send this PUT and after a minute, kill the request, send the POST and 🤞 it worked?

shelleydoljack commented 1 year ago

Ahh, okay, so the request I sent finally got a 204 response after about 5 minutes? Not sure it was 5 minutes.

shelleydoljack commented 1 year ago

Not needed anymore.