Am not using the focus node - as its an action on the graph as a whole
(attached to ontology as per suggestion in documents)
am using let thing =
I can try another level of wrapping - I was only able to make functions
visible globally using *.api.ttl -
if I declare the functions as dash:IncludedScript they fail to find the
global helper functions I declared in a *.api.ttl file. Importing this
function set graph into the resource script graph didnt help:
threw "ReferenceError: "dgf" is not defined" (dgf. is defined and can
access its functions via SPARQL and script editor)
The only reference to ShapeScript I could find searching the 7.2
documentation was
"On saving, EDG will automatically create an instance of type dash:
ShapeScript which is attached to the selected node shape. This will ensure
that the next time the node shape is selected, the defined function is
shown in the shape script panel."
So to attach it to the ontology to test that way I would declare
owl:Ontology dash:ShapeScript my:action
instead of
owl:Ontology dash:resourceAction my:action
?
On Wednesday, May 11, 2022 at 10:17:37 AM UTC+10 Holger Knublauch wrote:
>
> On 2022-05-11 9:56 am, Rob Atkinson wrote:
> > HI I have a script that behaves as expected in the script editor but
> > when run as a resource action behaves differently.
> >
> > two things
> >
> > - a script that extracts some data from an asset collection and then
> > inserts it into a different asset collection works from the script
> > editor, but when run as a resource action doesnt complain or but the
> > data doesnt show up in the target graph. (The function is tagged as
> > dash:canWrite true BTW)
> One potential difference could be the type of the variable focusNode.
> Are you using that variable in your scripts?
> >
> > and simpler case I noticed:
> >
> > script assigns a string to a variable using
> >
> > thing = `string template`
> >
> > when I run console.log(thing) in the script editor it shows, as
> expected:
> > "string template"
> >
> > but when I run this same code in an ADS resource action it renders it as
> > "[Object object]"
> Hard to say without seeing the surrounding code. But just doing thing =
> ... may be a variable scope problem. Have you tried using *let* thing =
> ... instead, to make sure the variable is locally scoped?
> >
> >
> > And finally:
> > - is there a way of invoking the resource action directly from the
> > script editor
>
> No but you could place the body of the resource action into a helper
> function with a globally unique name and put that into a
> dash:IncludedScript. For example
>
> function myResourceAction(resource) { ... }
>
> and then invoke myResourceAction(resource) from the Script Editor panel.
> Or attach it to a class as a ShapeScript if you prefer OO programming
> style.
>
> > - is there any way of using the script debugger from a resource
> > action, commit or other trigger ?
>
> No, this would be nice but quite hard to implement and get right. You
> can imagine that running the debugger is already quite a low-level
> operation... But maybe the above trick will help you debug this from the
> Script Panel. All you may want to add are some guard clauses to verify
> that the argument (resource/focusNode) have indeed the right type.
>
> Holger
>
>
>
--
You received this message because you are subscribed to the Google Groups
"TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/topbraid-users/51fdf23c-769d-46bb-bc04-7227ecc8cb3an%40googlegroups.com.