Write to tag

I created a tag under default and i want to change the value or write one into it.

[code]TagPath pathEcr = TagPathParser.parse("[default]New Tag.Value");
WriteRequest wr = new BasicWriteRequest(pathEcr, 9);

context.getTagManager().write((List<WriteRequest>)wr, null, true);[/code]

Im trying this but i cant get it to work. Neither can i find any proper documentation how to implement something as simple as this.

What do i need to do to write to the Tag?

Well, for starters, you can’t just cast a WriteRequest into a List, you need to create a new list and add your request to it. That’s probably the cause of any errors you’re getting when you try to run right now.

Beyond that it would be helpful if you included any error messages you’re getting, or if you’re not getting any and the call is actually completing, log the quality/result you get from the write call.

Hey Kevin,

Thanks for your reply. I managed to get it working with this piece of code:

[quote]TagPath pathEcr = TagPathParser.parse("[default]New Tag.Value");
WriteRequest wr = new BasicWriteRequest(pathEcr, 9);

List<WriteRequest> writeList = new ArrayList<WriteRequest>();
writeList.add(wr);

context.getTagManager().write(writeList, null, true);[/quote]

However it doesnt work with a Custom Provider that I am using. For example I currently have a Provider created with the simple tag provider.

Its name is [ABC]abc/abc/Quality.Value.

After compiling I tried it out but the provider [ABC] is just empty. Even if i refresh it with a button which normally always works, it doesnt get shown. I also debugged it and i see the provider getting filled but when i return to the Designer it still is empty.

I dont get any errors.

Any idea why my piece of code doesnt work with the simpletagprovider?

I solved the problem.

I had an * in the name of my Provider for example TEST*TEST/abc.Value.

When I tried to write to it, it fails. Creating a Tag Provider in the Designer wont allow the * character but if you create the SimpleTagProvider from a module there is no restriction on it.

Thanks to Kevin for pointing this out during the training.