Community

Formatting Field After Script Rule (Type Mismatch Error - System.Runtime.InteropServices)

Hi Everyone,

I have been trying to clean up some small things here and there but am not sure what to do for the following.

I have a couple scripts that help ABBYY to format and capture dates correctly in the doc def as I see many different formats, but after all the normalization's run in script rules, I get:

System.Runtime.InteropServices.COMException (0x80020005): Type mismatch.

The field in question is a date field.  I tried creating one last simple rule at the end of the chain to change the Field.Value to DateTime but that didn't work.

using System;

string Date = Context.Field("StartDate").Text;
DateTime newDate = Convert.ToDateTime(Date);
Context.Field("StartDate").Value = newDate;

I am able to get the documents through as it's only a yellow error but am wondering how I can make this not happen to make the UI and process smoother.

Thanks,

Was this article helpful?

0 out of 0 found this helpful

Comments

3 comments

  • Avatar
    Vladimir Dimitrijević Avaltek.com

    Hi,

    TryParse would be helpful in this case, or even TryParseExact.

    Best regards,
    Vladimir

    1
  • Avatar
    ElliotG

    Thanks!  I'll give this a try today

    0
  • Avatar
    ElliotG

    Vladimir Dimitrijević Avaltek.com , This worked, thanks so much!!

    0

Please sign in to leave a comment.