cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

Using "sourceProperty" variable with Dynamic Subscriptions

MarkCheli
12-Amethyst

Using "sourceProperty" variable with Dynamic Subscriptions

Hi All!

Part of my application allows the user to set up their own custom "If [condition] then [action]".  Currently I am taking their condition information and creating an Alert dynamically.  Now I am attempting to apply the action via a subscription that is also created dynamically.  Here's how I create the subscription currently...

var params = {

    propertyName: logicProp,

    eventName: "Alert",

    thingName: undefined,

    serviceName: "SubscriptionActionService"

}

me.AddDynamicSubscription(params);

This works, and the dynamic subscription does trigger the SubscriptionActionService.  However typically with a regular static subscription, you have access to variables from the event information from the alert, e.g. sourceProperty.  As you may imagine since SubscriptionActionService is abstract, it needs to be passed some information in order to execute the correct service.

Here's what I have currently for SubscriptionActionService...

var serviceName = me.logic[sourceProperty].actionService;

me[serviceName]();


Logic is a JSON property which contains a list of which services should be executed based on which property is triggering the alert.  The problem is that "sourceProperty" does not exist on dynamic subscriptions (based on my current knowledge).  I have also tried referencing the property via eventData.sourceProperty as well.  Is there another way for me to reference this information?  Alternatively, is there another way to dynamically execute a service/subscription as the result of an alert?


TLDR:  How can you access information about the alert event from a dynamic subscription?

1 REPLY 1
PaiChung
22-Sapphire I
(To:MarkCheli)

have you tried just 'source' ?

Announcements


Top Tags