7 Replies Latest reply on Mar 5, 2014 5:53 PM by arunans

    Server schedule job throws 401 error



      Server schedule job throws 401 error

      Your post


           We have a schedule job thats failing with 401 error. when the same script runs in client side it works perfectly. the script is like this

           error capture[on]

           perform find[restore]


           exit script[]


           sort records

           export records[]

           end if


           my findings were: we have given two criteria in the perform find: which has an AND condition. when i do not give the AND condition the script works well . whenever the AND condition is given the if(get{count)) returns only 0. But when i run it from client side the script runs very perfectly. i tried giving find and constraint find also. Still this particular script is throwing an error.I am unable to find out the root cause for this and fix it since when i run it from client side the perform find is happening perfectly. Only when i am running from server side this issue comes. please help me out with the same.

           Additionally there are no security issues related with this. i have thoroughly checked the same.



        • 1. Re: Server schedule job throws 401 error

               From my answer to your posting in the other forum:

               This is a thing from FM Server. 

               The 401 error means that no records are found, so I too am guessing that it is the Perform Find command that returns no records which is seen as an error by FileMaker. Using ErrorCapture seems logical, except that it only works within a client solution, not from within Server. So Server still thinks it is an error and logs it. Just like it does when in a loop the step Go To Next Record, Exit After Last produces an error after the last record; there is no next record after all, so again an error is logged.

               If you Google it a bit you'll find a couple of posts, f.e.: http://fmforums.com/forum/topic/86055-no-records-found-401-filemaker-script-error/

               There are several opinions on this across the net; I personally think a find command which produces no records is not an error, merely a FoundCount of 0, that is all. Others are on the side of FileMaker, so take your pick.

               I have never found a reliable workaround for this; suggestions that a script should end with a step that does not produce an error would not result in the logentries seemed to work sometimes but mostly not at all.

               Now, as a side note, the Export Records command is also tricky for Server as Server can only access specific folders. I think that it would produce a different error, but just for testing purposes you might want to disable it to make sure it is the find command.


          • 2. Re: Server schedule job throws 401 error

                 I also think that no records found should either not be logged as an error or the fact that it does should not keep a server scheduled script from executing to completion.

                 I just had a brainstorm for a work around. I freely admit that it's an awkward Kludge, but it should work around this issue:

                 Put a "dummy" record in your table with values in a field that keep it unique from all other records so that you can easily omit it from layouts, portals etc. (that's where this is awkward).

                 Modify your find criteria so that an added request will find this dummy record. Now your script will always find this dummy record even if no other records are found. Once you've performed your find, you can omit the record from your found set with either a constrain found set action or sorting your records to make the dummy the first record and using omit records to omit it.

            • 3. Re: Server schedule job throws 401 error
              hi phil and jan.. i have actually tried it that way. 1) i tried performing find alone and it works. the minute i give the find condition with the AND condition it fails. Herei would like to add that,the record has to fall in a particular file on the server. when i run the script locally it runs perfectly only when i schedule it n server and run it this fails giving 401 error. 2)So i gave the constraint find still it shows same error. I am totally unaware of why this happens since when i run it client side it works perfectly and in server side it doesnt find records.
              • 4. Re: Server schedule job throws 401 error
                when i tried debugging it i found that perform find is not returning any records hence i tried fixing a dummy value and ran. when run locally it does return record and goes inside the if loop.its oly when i am scheduling it and runnung from server this error happens.
                • 5. Re: Server schedule job throws 401 error

                       Phil, as far as I am aware the script still continues to execute after the error is logged. I have this situation f.e. in a scheduled script which checks for certain records in a couple of tables, divided over 4 find sequences. Usually nothing is found (correctly) and I get 4 errors logged in my log-file. So as fas as I am concerned it is a bit of a nuisance only, not a real problem. It is just that I like error logs to say Warning or Error only if there actual issues; now I have to filter through them to see if they are server-script related or not. Your workaround is certainly an option! 

                       Aruna, do you test the script in another file or in the same file with the same with the only difference being that is run on either client or server? When run on the server, can you verify that the script does enter the if statement? For example by setting a debug-field to a value saying that is in either the IF part or the ELSE part (and just to be on the safe side, disable the Export Records step for a moment just to be sure that it does not confuse things)? If it does continue then only an error is logged and, as I mentioned earlier, this is specific to FM Server and as such 'expected behavior'. 

                  • 6. Re: Server schedule job throws 401 error

                         If the script runs correctly but you have a spurious error logged in the server--which is what I see in an older version that I am using--so I'm glad that the newer versions didn't change this behavior, then I wouldn't try this work around just to eliminate a logged error code.

                    • 7. Re: Server schedule job throws 401 error
                      hi jan and phil... i debugged it and found that one of the field was referring to an internal layout where the password had to be reset due to which this error had been thrown.. thanks a lot jan and phil. i am very new to filemaker hence have very low understanding of the same.