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

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

how to create service using JavaScript code in particular Thing

Hariharasuthan
13-Aquamarine

how to create service using JavaScript code in particular Thing

how to create service using JavaScript code in particular Thing. I created new Thing code using but how to create service using JavaScript code in particular Thing code.

 

step1:   Thing created using JavaScript code.

 

var params = {
name:"Scheduler_Dynamic_CRON139ol" /* STRING */,
description: "DEMO Scheduler With CRON dynamically set" /* STRING */,
thingTemplateName:"MyCustomScheduler" /* THINGTEMPLATENAME */,
projectName:"MailserverGoogle" /* PROJECTNAME */,
runAsUser:"Hariharasuthan",
schedule:"0 0/1 * * * ?"

}

Resources["EntityServices"].CreateThing(params);
};

 

step2: below this is service code but how to implement in Thing(step1) using code wise implementation?

Things["Mailserver_google"].SendMessageWithAttachment({
cc: "harisuthanlive@gmail.com" /* STRING */,
path: "52.xlsx" /* STRING */,
bcc: undefined /* STRING */,
subject: "me test Report one mintues " /* STRING */,
fileRepository:"SystemRepository" /* THINGNAME */,
attachmentName:"52.xlsx" /* STRING */,
from: "jjj@gmail.com" /* STRING */,
mimeType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" /* STRING */,
to: "jj@gmail.com" /* STRING */,
body: "Report At"+datetime/* HTML */
});

 

 

 

ACCEPTED SOLUTION

Accepted Solutions

@Hariharasuthan 

 

I have never created dynamic services like this nor ever had the need in my years of developing in TWX.  Is there a reason you can't create these services on your custom thing template and use parameters to fill out the appropriate fields?

 

Thanks,

 

Travis

View solution in original post

3 REPLIES 3

Hello @Hariharasuthan,

 

There are multiple posts on this forum asking this question:

https://community.ptc.com/t5/ThingWorx-Developers/Create-service-programmatically/td-p/518587

https://community.ptc.com/t5/ThingWorx-Developers/Modify-service-code-programmatically/m-p/515218

And also here is a PTC article: https://www.ptc.com/en/support/article/CS372728

 

My understanding is that it isn't really recommended to do this, even though there are some ways of "kinda" doing it.

 

Regards,

Jens

Hariharasuthan
13-Aquamarine
(To:jensc)

Hi jens 

 

i try inthis code test  but not reflected ,so need simply  way code please share to me 

 

my requirement Is:

particular thing in create new services  

 

 for example

 

var params = {
name:"Scheduler_Dynamic_CRON139" /* STRING */,
projectName:"MailserverGoogle" /* PROJECTNAME */,
runAsUser:"Hariharasuthan",
schedule:"0 0/1 * * * ?"
};

Resources["EntityServices"].CreateThing(params);

this code was create new thing, but i need to same thing new services how create  ?

@Hariharasuthan 

 

I have never created dynamic services like this nor ever had the need in my years of developing in TWX.  Is there a reason you can't create these services on your custom thing template and use parameters to fill out the appropriate fields?

 

Thanks,

 

Travis

Announcements


Top Tags