4 Replies Latest reply on Jun 27, 2016 10:16 AM by dcbb RSS
    hoono Explorer

    About Add an Alert

    Hello Adam,

    I met a trouble when i tried to create an alert on a property. I found the service "AddOrUpdateAlert" and wrote an example in below.

    // test example var table = attributes.alertAttributes; var params = {   alertType: "Above" /* STRING */,  alertName: "h_above" /* STRING /,    property: "humidity" / STRING /,    description: "humidity above threshold value" / STRING /,   attributes: ???? / INFOTABLE /,     priority: 1 / INTEGER /,    persistent: true / BOOLEAN /,   enabled: true / BOOLEAN */ }; me.AddOrUpdateAlert(params);

    But there is a parameter that called "attributes" and type is INFOTABLE. I want to know what is mean about this parameter. Can you give me some advice/hint about how to create/modify an alert ? Thank you so much for your always support.

      • About Add an Alert
        adam Creator

        Hi Hirotaka,

         

        The attributes parameter is where you specify the value or values for the alert. This needs to be documented, but since you provided a code sample for the alert you want to create, I can provide the following snippet which will create an

        InfoTable

         that will work for your particular use case.


        var alertAttributes = Resources["InfoTableFunctions"].CreateInfoTable();


        alertAttributes.AddField();

        alertAttributes.AddField();

        alertAttributes.AddRow();</div></div></p>

          • About Add an Alert
            hoono Explorer

            Hi Adam,

            I used your snippet and successfully add/update an alert.
            Thank you for your help.
            Have a good day!

            • Re: About Add an Alert
              mbereket Apprentice

              Hi Adam,

               

              Do you know how can I do the same thing with REST API calls, imagine a web site using thingworx only with its REST calls, so in my case, I dont know what would replace the snippet you gave.

               

              Anyway, So, What I would like to do is to make a POST request to add an alert and I would like to send the following JSON like Hirotaka:

              {alertType: "Above",

              alertName: "h_above",

              property: "humidity",

              description: "humidity above threshold value",

              attributes: ????

              }

               

              any ideas?

              Thanks