Can someone put on the right path... I'm trying to create a script that will build or create a dataset... This is what I "think" needs done, just not sure on the proper execution...
function jobArrived( s: Switch, job: job )
var theDatasetName = s.getPropertyValue("DataSetName");
var theKey = s.getPropertyValue("Key");
var theValue = s.getPropertyValue("Value");
I would guess that I need to map the key and value to the dataset, just not clear on the proper way to do that...
Thanks in advance,
Anthony
How to create a dataset
-
- Member
- Posts: 32
- Joined: Fri Mar 24, 2017 7:06 pm
- Location: Cleveland, OH
Re: How to create a dataset
For simple key value pairs its much easier to write to private data -- but here is an example of writing to a dataset:
- https://github.com/open-automation/swit ... #L324-L367
- https://github.com/open-automation/swit ... #L324-L367
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore
Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
Free Switch apps: open-automation @ Enfocus appstore
Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
-
- Member
- Posts: 32
- Joined: Fri Mar 24, 2017 7:06 pm
- Location: Cleveland, OH
Re: How to create a dataset
Thank you!
-
- Member
- Posts: 32
- Joined: Fri Mar 24, 2017 7:06 pm
- Location: Cleveland, OH
Re: How to create a dataset
Ok... This may be a dumb question, but is there a way to attach a complete dataset to one private data key...?
Re: How to create a dataset
No dumb questions here. I haven't used Switch in a little while but here's my take on this.apietrocini wrote: ↑Wed Mar 13, 2019 9:31 pm Ok... This may be a dumb question, but is there a way to attach a complete dataset to one private data key...?
The private data methods (setPrivateData, getPrivateData) allow you to set and get strings (https://www.enfocus.com/manuals/Develop ... class.html). They usually aren't used to access sets of data -- more often for simple key/value pairs (example of two private data keys: MyJobNumber => "123456", MyCustomer => "Acme Corp"). But in that example, we have two related pieces of data saved as two keys (MyJobNumber and MyCustomer), so one might say that is a "data set". In fact, the "multiple result value" option of the script I gave you encodes a result of data into many PD keys (e.g. row1, row2, row3).
But a string is a string, so you could encode some form of dataset as a string, set it, then get it again. For example, let's say you had the JSON object:
Code: Select all
{
"this": "that",
"these": "those"
}
But Switch's first-class handling of Datasets is better suited for this job -- if you can get past the fact that they are a little harder to use (harder then setting private data anyways). You can do it a few ways -- but the most straightforward is to create an XML structure of your document and use that.
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<this>that</this>
<these>those</these>
Code: Select all
[Metadata.Text:Path="/[tag='this']/value",Dataset="MyDataset",Model="XML"]
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore
Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
Free Switch apps: open-automation @ Enfocus appstore
Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
Re: How to create a dataset
There is an app for that
With the App "Make XML" you can create your own dataset form variables in Switch or write your own values.
The App can save this as an XML file or as a Dataset.
https://www.enfocus.com/en/appstore/product/make-xml
With the App "Make XML" you can create your own dataset form variables in Switch or write your own values.
The App can save this as an XML file or as a Dataset.
https://www.enfocus.com/en/appstore/product/make-xml
-
- Member
- Posts: 32
- Joined: Fri Mar 24, 2017 7:06 pm
- Location: Cleveland, OH
Re: How to create a dataset
Thank you!!! I got it to work!
Re: How to create a dataset
Thanks for sharing great information on data set, keep sharing.