6 Replies Latest reply on Sep 19, 2016 4:55 AM by smiddleton

    Input string was not in a correct format

    Stephen_Justice Rookie

      Hi,

       

      I'm currently working on a window calculation for a window that has a lot of attributes.

       

      I've went through it line by line, letter by letter, over the last two weeks and believe I've fixed every single bug or misplaced character I can find.

       

      However when I attempt to run it, the portal gives the error "Exception has been thrown by the target of an invocation"

       

      When I pull up the logs I get a more detailed error message, but I'm not sure I know what it means.

       

      Calculation

      Attribute Calculation Unsuccessful at 2016-08-10 11:44:26.984

      Calculation successful for Attribute [_AssetLargeCalculations] on Class Type [IncidentManagement.Incident]

      On Object : Key = [431b71be-1ab9-4226-bc08-4cb6506f3e26]  Name = []

      Calculated Value = []

      FAILED

      Input string was not in a correct format.

       

      I thought it was because I typed something in wrong, hence the detailed checking, but I even after fixing up the two instances where I liked , instead of ; it still doesn't appear to work.

       

      Does anyone know of an easy way to find out what I've done wrong?

       

       

      I've attached the script if anyone cares to have a look over it, but as you can see it's no small thing.

        • 1. Re: Input string was not in a correct format
          Mariusz.Maniak Expert

          Wow!!! Amazing calculation

           

          You can try to trap error following this doc:

           

          Trapping calculation errors and finding which line it occurred on

           

          also, as You checking two processes - maybe it will be easier to prepare two windows - one for Incident.Lifecycle.Title == "Issue of Asset", second for Incident.Lifecycle.Title == "Physical Relocation", should be easier to manage this calculation.

          • 2. Re: Input string was not in a correct format
            andreas.lindner Expert

            Hi,

            I've just had a look at your calculation and the first thing I would do is to get rid of all blank spaces in the command itself so that it looks like this:

            ":SetHidden(_Attribute,{0});:SetMandatory(_Attribute,{1});"

             

            Or maybe the String is too long or the parameters are to many. Have you tried to shorten it by half and try it our again?

             

            Andreas

            • 3. Re: Input string was not in a correct format
              Stu McNeill Employee

              Hi Stephen,

               

              After I picked my jaw up off the floor I skimmed your beast of a calculation and noticed a couple of lines that might be causing the error:

               

              if Incident.Status == "Waiting on Asset Details from User":

              and

              if Incident.Status == "Waiting on Asset Preparation":

               

              Those should probably be checking Incident.Status.Title.

               

              I'd then consider trying to simplify your forms and/or take a holiday!

              • 4. Re: Input string was not in a correct format
                Mariusz.Maniak Expert

                One more thing - is there any limit for output string? Maybe result is just too long?

                • 5. Re: Input string was not in a correct format
                  Stephen_Justice Rookie

                  Thanks for that bit of code, I think that'll come in useful quite a bit in the future.

                   

                  Unfortunately all it did was point out it was the return line that was giving the "Input String not in a correct format" error, so didn't add anything new here.

                   

                  The part for the Issue of Asset has worked previously by itself, and the Physical Relocation was added later on.

                  My hope had been to just have one piece of code for all windows and processes, so I just had to have one return string for all attributes.

                  Then whenever I needed to create a new process and window, I could just write on a new section, and have it work.

                  Unfortunately that doesn't seem to be the case.

                   

                  I tried separating the two parts.

                  The Issue of Asset has went back to working.

                  The Physical Relocation continues to still not work.

                  Given that the first just has 82 attributes, and the later has 480, I'm starting to wonder if it is just the sheer size of it all.

                   

                  Guess next step is to try with just a few sections at a time and getting it working, slowly adding more until I find if there's an upper limit.

                  • 6. Re: Input string was not in a correct format
                    smiddleton Expert

                    Wow, just yeah....

                     

                    so having a quick look I think you have an issue with ":SetHidden(_NPCLocation5, 148});"

                    Its missing a { opening bracket so should be ":SetHidden(_NPCLocation5, 148});".

                     

                    And as already suggested your checks against status should really use either .Title (could change) or .Name (very unlikely to change).

                     

                    If your going to continue keeping this as 1 big calc you might find some mileage in separating the return string into sections by creating multiple value attributes and then returning them formatted together.

                     

                    That way when you want to add something just create another value attribute in the calc, perform the required checks and fill it with String.Format and then append to the return value again using String.Format.

                     

                    Slightly easier to diagnose as you can easily then include or exclude various sections easily.