bonjour hi welcome to another video of cloud
in five minutes I'm Frank Boucher and
today I want to show you how to add
inline code directly inside your logic app
 
in a project I'm working on right now I
I needed to manipulate some string
inside the logic app I could have create
an azure function and do my work over
there but there's a new functionality
named code in line that give me that
opportunity opportunity so let me show
you here I have a very simple logic app
and because it's a demo we'll keep the
recurrence every three months what I
want to do is read that file here simple
notes that contain a string and at the
end of the string between square
brackets I have tags so I want to
extract those tags and make two
different string to do it what I will do
is first read that file so we'll need to
use the onedrive connector there it is
and I want to read the content of the
file so here I have a get file content
just here so if it's not done yet you
will need to authorize logic app to
access your onedrive folder and then you
will be able to select the file a simple
note just here perfect so now let's add
one variable just for fun I will explain
later what we'll be using it for
so initialize we'll call that variable
clean note and I will set it as an
object great so now let's save it for
code in line to be able to access the
workflow properties I need the
integration account so let's add one
first to create one of those account
it's very simple click in the top left
corner of your screen the green button
and then search for integration you have
integration account you click here you
click the blue button create you fill
that form and after just a few second
you have your new account now let's go
back to their logic app so now I'm in
the logic app I need to assign this
integration account to my logic app it's
very simple you go in the
panel in the properties and you select
the workflow settings and here
integration account you just need to
pick it for me it was already set that
don't forget to save and now you can
continue to edit your logic app so go
back in the logic app designer or
through the overview click the edit
button so now we are ready to add the
code so let's look for it and here we
have it inline code at the moment to
rearm recording this video it's only
execute JavaScript code and it's in
preview but it's working very well
because the window is it that small let
me show the code in my visual studio
code editor so err it is you will see
it's very simple so on the first line
what I do is create a variable name note
and I will go access the workflow
context and this context has access to
the actions and trigger in my case I
want to access the action name get file
content I will show you later where that
name come from
and then from the output along the body
that will result exactly at the content
of the file so after that it's just
JavaScript so I will create a variable
to identify the last location of the
square brackets then I create an empty
object and assign the property where I
will be doing a substring like
extracting part of the string
so now let's copy that in logic app
great let's save it and there it is so
remember that name get file content well
it's from here all spaces are replaced
by underscores and if you're not sure
you can always go in the code view
because remember a logic app is in fact
a big JSON file and then you will see in
the actions you will be able to find
your agate file content available
now let's go back in designer and
remember that variables I created
now let's assign the result of our
inline code to that variable so new step
then variables I will do is set
variables I'm picking my clean note and
I will assign the result if for some
reason the result properties is not
available you can always add it manually
remember you go in the code view and you
will be able to it to add the execute
JavaScript code buddy it will look
exactly like this outputs and then
between parentheses executes JavaScript
code or the name that you gave if you
rename it and but the interrogation
point here is just to specify maybe the
body is empty great now we have all we
need
let's run it don't forget to save and
now let's run it of course it's a very
simple logic app so we'll take only a
few seconds
voila so now if we have a look we'll see
that the code was executed and we have a
property so just the tags here and just
the message here and if we look again in
the variables of course it's the same
settings this way you will be able to
add code seriously inside your logic app
without having to create and deploy a
shape functions or AP is I hope you
liked this video and I hope it was
useful don't forget to subscribe and
click the bail icon this way you will
receive a notification every time I
publish a new cloud and five minutes
video if you want to know more about
logic app you can watch those videos
thank you for watching see you next time
the Xterra
the intergate the interior the interior
aha
