[Music]
hello everyone welcome to another video
in this video we will solve an issue
right what is that issue
in power automate sometimes whenever we
are dealing with files in sharepoint
we are getting lock error
it will display the error like the file
is locked by some other process so you
cannot do any operation on that file for
example you want to move the file from
one folder to another folder my
intention is
i have a file here excel file and here
this is the table and the table name i
have created is double one
and my intention is whenever this excel
file with table one will be uploaded
here in my sharepoint
folder raw folder
as soon as it is uploaded i want to read
the table information
available in this excel sheet
in power automate then after reading
that records i want to move the file
from raw
folder to processed folder
okay
now what will happen let us check
i'll go here and try to create a flow
i'll click on automated cloud flow click
on skip
i always try to skip because uh it will
give you more space to define the things
let me give a name
process
excel
in sharepoint
okay i've just given a name
and i will use the sharepoint connector
why because my intention is whenever a
file is uploaded here in the raw folder
so the trigger is when a new file is
created
i want property only when a file is
created property only
take the site address what is my site
address my site address is this one d365
files how to know that you will see here
the url
sites
slash d365 files i have created this
communication site in sharepoint
and in this
site i have created two folders raw
folder and processed folder
so i have created site address
associated and library i can choose
document which folder
i want to use that raw folder so go to
shared document
and
raw folder
so what this trigger will do as soon as
you upload a file on the raw folder in
this site it will trigger
what i want to do i want to read
the excel file that is uploaded in the
raw folder
as we have mentioned here in the folder
and we want to read the
table information available in the excel
sheet so take another step
and search excel online business
i want excel connector and i will use a
step action step called as
get
a list row present in a table right so
this step or this this action can be
used to extract the tabular information
available in an excel sheet i read all
these informations
now i have to provide the location what
is the location the location is the site
name the site name is available here
sharepoint site
what is the document library the dial
libraries documents what is the file
which file you want to read
the file that is triggered this flow so
where the file path is available that is
available in this trigger so you can
short share the file
and here you will get the full path so
this full path
is the
complete absolute path of the file that
is just uploaded which triggered this
flow
which table i want to read i want to
read the table if it is not displayed
use custom
and give the name of the table my table
name is table1 how can you understand go
to here and
select this drop down you will see the
table one
so this table information i want to read
so i have given table one
so this step is reading the records of
that table present in the excel sheet
now once it is success what i want to do
once it is completed i want to do
another step
i want to move the file from this folder
to
this folder processed folder so what i
can do i can
take
another
control another action move file
that is available in the sharepoint
so there is a file action
you have to provide the move file
information what is the current site
address the current site address is this
one a365 files
which file you want to move
i can give dynamic value i have full
path with me
what is the destination site i want to
move this is the destination site which
folder you want to move the folder is
available in the
shared document
and processed so this is the target
folder
if another file is already exist with
same name what you want to do i want to
move with a new name
right so i have taken three steps this
is the trigger which will trigger the
flow when a new file is created
the second action will read all the rows
from the table from that excel sheet and
after it is reading it will move the
file from source to destination from raw
folder to
from raw folder to processed folder
right
now save this
and try to test
okay i want to test it
so how to test it you have to upload a
file i will go to raw and upload my file
i have this file with me just close it
and upload in the
raw folder
so this is the
excel file i have uploaded
as soon as i upload the power automate
should run
and it should
execute all the steps but
you will get error in the last step
why you you will get error because
whenever the power automate will try to
process the excel sheet
uh it locks it it keeps a lock on the
file so that any other process cannot
do any and cannot do anything on that
form on that file that's why it is
trying to read the
uh file info the table information using
this step it creates a log sharepoint
itself creates a lock on this file
on this file which file is this this one
and it's because because of this log
implemented the move file failed
with this region
why cannot be moved because it is locked
mode
so power automate power automate itself
retrieves information because of this
the sharepoint locks this file
okay
so how to handle this
i have completed my process but i want
to move it and the lock is still there
so here you need to do some extra work
what extra work you have to do
you have to first take a variable how to
resolve this
take a variable
and this variable
initialize the variable
and give the name edge
log file
you can take any name log file boolean
and i want to give boolean edge true
expression
and make it true
that means
by default the log file boolean variable
is true
next what i want to do i want to do a
loop add action
use control
and use do until step
what i want to do
how many times the
loop will run
until unless this log file becomes false
so write down
select here log file is equal to
false
so till this log file is for initially
it is true
and the loop will
run till the log file is false now there
should be something some step which will
make this file this variable false
so what it will do what we will do just
move this move file step inside this
do until loop
so the move file step will run in a loop
now this will not resolve the uh this
will not resolve the issue we have to do
some more steps how to make this log
file variable as false
because otherwise it will keep looping
um
always infinitely if the
variable value will not become false
so take another step add an action
and here i want to set the variable
now okay
first we need to let us do one thing let
me save it
what we want we want to
because we have seen that in our last
run it was throwing error
so when it was thrown error we have to
copy something because we need here
so save this first
go back to the run status
open the last failed step
and go to that step
where it was throwing error
and
go to this body section and copy the
entire response
copy this
now click on edit
because that response we need because we
have to pass that
response
now after this move file i want to add
an action called as pass session
huge power station why i'm using power
station because i want to extract the
properties from the body response of
this step
so which content i want to pass i want
to pass the body of the move file
with schema what is the schema of this
response i have already copied click on
generate from sample and put it here
it will generate for you
remember
this parse session will only execute if
this will fail
so what you can do click on this
partition and click on configure run
after
and use if the move file has failed
click on done so what will do what it
will do this past session will only
execute if this step will
fail
now after this step
because it is
running through loop right so i want to
add another step after this
if power station is
passing the content of the body response
in this step i want to add another step
what i want to do i want to set the
value of this variable
by conditionally to check or to make it
false how to do that
take variable
use set variable
and use the variable log file and what
is the value i want i want to do
something i have to write
the
logic expression
what i want to write i have to check
if
this is the expression you can use if if
the message
sorry we have to use contents formula
expression
if the message message message is from
power station step
if the message contains
if this message contains
comma
locked because this message always
contains locked message
if it contains locked what i want to do
i want to set as true
else it is false
okay
so what it will do
it will set the variable value by
checking the condition if the power
station pass session will just
pass the gesture object
of the body response of this step
and the power station
extracts the information like message
and message and status of the response
i am checking if the message contains a
word called as locked
locked then
it will make false sorry it will make
true that means it is still locked
otherwise
it will
make the
what happened
[Music]
uh let me just remove this
go to expression and put it
okay write down
if
this contains
if this contains locked
then
assign value h true otherwise make it
false
right so
in loop so when it will when this set
variable step will run whenever this
will be success
so go to here and configure on after
already there if it is success the last
step is success passages and step is
success then it will set the variable
otherwise it will not do that
right so in the loop
it will try moving the file again and
again
and checking the error message if error
message is
error message contains locked field then
it will set the value as true otherwise
it will set the value as false and if it
is false it will stop the
execution
this way we can give some time to the
flow to keep waiting till the lock is
removed
click on save
right
once it is saved what i can do
let me i have already created another uh
flow let me
turn off that
so this is the file i have this is the
flow i have created just now
so let us test this
let me go to the sharepoint
i have already
two folders
everything is blank
just click on test manually
now once you are testing you have to
upload a file go here and upload a file
i have uploaded the file i am expecting
the flow will run
now this time the error will not come
but it will keep waiting for some time
and try to move the file from raw to
process the folder
by checking the lock
message in the return message once the
error will not come it will try to move
that means when the locked
locked condition is removed from the
sharepoint it will try to move
because we do not have control over the
lock system of the sharepoint on files
now let us wait
so it will try to run the flow because
yes now
the first trigger is done listing out
the records is done initialize variable
is done now it is trying to move the
record move the file
from raw folder to processed folder it
is still trying to check the lock
if the lock is removed then only it will
try to move otherwise it will keep
failing right
you will see one thing so let us wait
for some time
now after five minutes you will see all
steps are executed and the flow runs
successfully
how it is done and the file also moved
from raw folder to processed folder
and how it is done
and this is done because
and as you see in the process it is
moved now this is because
the loop is running
and you see first time in the first run
it it run 60 times you see
the do one until loop running 60 times
and on the
59th step it was
it was seen that there was
the move highway success that means
starting from first loop to 59 loop it
was throwing error this move file was
throwing error that means the lock was
implemented
and we are trying to check the power
session you will see in the first step
we are getting this error
lock error
in the second also second loop
if you check it you will also check we
are getting this error message in the
message
but if you go to 59
then you will see
the error is not there because this 2 is
not implemented and the body is having
different content there is no error
right
that's why
implementing this logic do while loop
is important if you want to manipulate
the files in the sharepoint
thank you for watching this video
uh please subscribe this channel if it
helps
i will come with new videos thank you
guys bye
[Music]
you