Trigger event when iparams are edited

We get couple of parameters as part of installation which includes freshdesk api key and domain. But our customers tend to edit it after installation maybe caz they reset the API key or for some other reason. But since there is no onEdit event triggered our middle-ware is not updated with the new details. So a lot of customers are blocked by this and they had to reinstall the app.

1 Like

Hi @arun.nasarain

Have you deployed the app in freshdesk portal or is middleware directly using admin portal for getting the credentials ?

Thanks

2 Likes

Hey @arun.nasarain,
Good Day!
We are not yet supported the app Iparams edit / update event,
correct me if I am wrong, your APP will call an API (middleware) with API key and Domain name when there is an install by app install event?

Thanks

Hi @Janani

Sorry for the late response.
The app is published in FD marketplace already.

Thanks

Hi @Santhosh,

Sorry for the late response.
Yeah almost right. I will give you a better understanding .

Customers give the FD api key and couple of other params while they install our app in FD.The middleware saves these details in the DB. But since FD has an option of resetting the fd api key people tend to do it and when they edit the iparam of the app, the middleware isn’t aware of it as we don’t t have any event triggered.So people have to reinstall the app which is a huge data loss for them.

Hope i m clear.

Thanks

@arun.nasarain
Yeah, I Understand,
Are you calling your middleware in iparams.html/Iparams.json or via app set up events?
if you are calling it via iparams then there is a way to identify if the app is in edit/new mode based on that you will call your API
eg: client.iparams.getState() -> will return new/upgrade/edit
Note: it is available only on the Iparams page

or if you are using app setup events then there is no such event for an app update.

Hope it helps

Thanks

Hi @arun.nasarain If the app is installed in the FD then you can use iparams.html and when the APIkey or domain is changed then you can trigger that to middleware using API(This API is a route or endpoint to middleware).

Or you can even use iprams.json in which you can use js to send the API key and Domain to middleware.

For iparams.json, create an assets folder under the config folder within the folder add iparams.js(example : config/assets/iparams.js) and declare a function using request API you can make an API call to middleware and update the API key and token.
Sample iprams.js code :

app.initialized().then(
    function (_client) {
        window.client = _client;
    },
    function (error) {
        console.log(error);
    }
);
function validate() {
    let domain = utils.get("domain_name");
    let api = utils.get("api_key");
    if (domain !== '' & api !== '') {
        var headers = { // Middleware Auth };
        client.request.post("URL", { headers: headers }).then(
            function (data) {
               console.log("data",data);
            },
            function (error) {
                console.log(error)
            }
        );
    }
    return "Success"
}

Sample iparams.json

"api_key": {
        "display_name": "Api Key",
        "description": "Please enter your api_key",
        "type": "api_key",
        "secure": true,
        "required": true,
        "events": [
            {
                "change": "validate"
            }
        ],
        "type_attributes": {
            "product": "freshdesk"
        }
    }

Hope this helps you :slight_smile:

Thanks,

3 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.

Hi @arun.nasarain,

@Janani’s suggestion would work for your use case. We also have a demo app that showcases this use case.

Thanks a lot @Janani @Raviraj .

2 Likes