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

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

How to call one service in another service using java script?

Surekha
12-Amethyst

How to call one service in another service using java script?

Hi,

 I have two services. One contains all data(One of the columns is a number which is got from SQL query) and another service which is used to convert the number to DateTime(Javascript).  Now i would like to modify all numbers to DateTime using another service. Is it possible? Please, anyone, help me out on this.

 

Regards,

Surekha N.

1 ACCEPTED SOLUTION

Accepted Solutions

// use first service result: DATETIME as input to second service
var input = me.GetDateTimePropertyValue({
propertyName: me.lastConnection/* STRING */
});
// result: INFOTABLE dataShape: "DateTimeValueStream"
var result = me.QueryDateTimePropertyHistory({
oldestFirst: undefined /* BOOLEAN */,
maxItems: undefined /* NUMBER */,
propertyName: undefined /* STRING */,
endDate: undefined /* DATETIME */,
query: undefined /* QUERY */,
startDate: input /* DATETIME */
});

View solution in original post

5 REPLIES 5

You can only return one result in the script but you can call several services inside. just use add service - entities to find the service you want.

 

var params = {
propertyName: undefined /* STRING */,
value: undefined /* DATETIME */,
timestamp: undefined /* DATETIME */
};

// no return
Things["azureRhel-AnalyticsServer"].AddDateTimeValueStreamEntry(params);


var params1 = {
property: undefined /* STRING */,
message: undefined /* STRING */
};

// no return
Things["azureRhel-AnalyticsServer"].AcknowledgeAlert(params1);

 

These 2 services won't interfere with each other, so they can run in order.

Surekha
12-Amethyst
(To:zyuan1)

Hi @zyuan1 ,

     I want to pass one service data to another service here.

 

Regards,

Surekha N.

// use first service result: DATETIME as input to second service
var input = me.GetDateTimePropertyValue({
propertyName: me.lastConnection/* STRING */
});
// result: INFOTABLE dataShape: "DateTimeValueStream"
var result = me.QueryDateTimePropertyHistory({
oldestFirst: undefined /* BOOLEAN */,
maxItems: undefined /* NUMBER */,
propertyName: undefined /* STRING */,
endDate: undefined /* DATETIME */,
query: undefined /* QUERY */,
startDate: input /* DATETIME */
});

This consists of 2 separate services, use first result as second service input

slangley
23-Emerald II
(To:zyuan1)

Hi @Surekha.

 

If the responses provided by @zyuan1 answered your question, please mark the appropriate one as the Accepted Solution for the benefit of others with the same question.

 

Regards.

 

--Sharon

Top Tags