Proper syntax for adding user to tag group?

i hope the screenshot encapsulates what i'm needing to know. what is not in the screenshot is that i cannot find where the proper syntax is for building a proper dataset for this method.

when we add a user to the Ignition Gateway (IG), we also need to populate the Users tag group with that user and a baseline dataset of assets and settings, blah blah blah. i am tasked with doing BOTH of these things programatically through a UI. i have the IG part working just fine, this is the part that's un-fine. :stuck_out_tongue:

I don't have an answer, but what I would do (and have done) is create one manually and then export the tag to see the structure. Then use that to build the tag(s) programmatically.

2 Likes

Any reason this is not going into a database ?

I guess what I'm asking is "What do you do with the users tags ?"

1 Like

i had a chat with Ignition support and they said that storing the small bits we had in the project was fine given two factors: 1) ease, 2) the previous 100 projects were done that way. Legacy. my wont is to go straight to a db. and i still may, but for compatibility with Legacy stuff, *ominous tone* THIS IS HOW IT HAS BEEN DONE FOR A THOUSAND YEARS! *ahem*. :smiley:

and, in truth, this is a many-to-many data problem that i don't have time to plot to a proper db structure, much as i want to. i just have to get this working correctly enough that i don't have a complete dumpster fire to come back to and move on to the next fire. :fire: but there aren't many more to put out and then my life is refactoring and streamlining and resetting to a standard.

for now: :fire: + :shower:

@jlandwerlen fantastic idea. i have to remember that i can do that!

To answer your question, this is what you're looking for:

tag = {
         'name' : 'iansebryk_data',
         'tagGroup': 'Flarn',
         'valueSource' : 'Memory',
         'dataType':'Dataset',
         'value': The dataset you want to provide
         }

system.tag.configure('[]/Users/', tag, 'o')

In your screen shot you set a collisionPolicy variable, but you don't actually send that to system.tag.configure().

Memory is the default value source so, when you use value.valueSource you get a memory type, but you aren't actually setting that, instead you are adding custom properties to the tag, which is what the blue values at the bottom of the Tag Editor are.

I do believe there is a better way to do what I believe you're trying to do.

I have a "base" UDT type, that I add into most of my other UDTs. One tag is a dataset where I define groups. I scratched my head on how to add rows and finally just exported a tag to see what it needed. I never would have guessed without it. Perhaps a document tag would be easier?

1 Like

@lrose did you get that to work, or is that assumed? I tried doing exactly that and it didn't like a dataset being presented that way.

Edit, the only way I could get it to work was present the value like this:

tagGroup = "{\"columns\":[{\"name\":\"Name\",\"type\":\"java.lang.String\"}],\"rows\":" + str(rowData) + "}"

If configure fails, configure the tag with a null value then write the dataset with writeBlocking separately.

I just tried this:

ds = system.db.runNamedQuery("sandbox/test")
tag = {
  "valueSource": "memory",
  "dataType": "DataSet",
  "name": "foo",
  "tagType": "AtomicTag",
  "value": ds
}
system.tag.configure("", [tag], 'o')

And it works just fine

1 Like

I assume that your named query is configured to return JSON?

Nevermind

No, wait, can you even do that with runNamedQuery ?
It's a dataset tag, so it takes a dataset as value.
I'd need to change its dataType to "Document" if I wanted to use json.

1 Like

Nope, you're correct. It returns a pyDataSet.

I should know that. :man_facepalming:

yeah. i exported the dataset, as @jlandwerlen advised (spot on advice, BTW), and noted that the letter case was wrong and i was targeting the wrong attribute AND i learned how the dataset is properly formed as well. turns out, case mAtTeRs! and i'm all for that. :+1: i am also all for targeting correct attributes... very useful methodology. :smiley:

fun twist to the story, my doc-averse predecessor apparently wrote a script that does what i'm trying to do, but stuck it on a button, instead of making a script in the library that we could bind to... and now we have to find the project with the magic button... might just say :fork_and_knife: that and just keep going.

this forum rocks. you guys are so helpful. thank you.

EDIT: in response to your question @jlandwerlen, yes. i got it to work using the dataset format from the exported tag. it did NOT work the way i had presented it. and, yes. i would never have guessed the format either.

1 Like

I was creating a UDT instance and then trying to write to an element that was a dataset type. I wonder if there is a difference there? If I have time I will try again, but I know I'm not dreaming this as I spent a good hour of my life on it. :slight_smile:

I was considering just using system.tag.write, but I ended up getting it to work.

I tried it with system.util.jsonEncode(system.dataset.toDataSet()) and that also worked. But perhaps it being a UDT instance makes a difference.

1 Like