Process Mapping Logo

Process Mapping - Forums

Sharing 19 years of knowledge and experience

 
Metastorm BPM forums
Sign up Latest Topics
 
 
 


Reply
  Author   Comment  
Jerome

Avatar / Picture

Guru
Registered:
Posts: 5,507
Reply with quote  #1 
So you thought calculating a date was awkward? (see Datetime calculations fail when date is 'never' )

Welcome to awkward^2.

I have a simple duration like so:
CalculateDuration(EM_EquipmentFaultData1.ReportedOn, DateTime.CurrentDate, DateTimeUnits.Days)

but I decide I want it to be "3" if the date is not set. So I change it to:
If(EM_EquipmentFaultData1.FixedOn == Never(),CalculateDuration(EM_EquipmentFaultData1.ReportedOn, DateTime.CurrentDate, DateTimeUnits.Days),3)

On deployment, I get the wonderfully informative error:
Quote:
The type arguments for method 'Metastorm.Runtime.Core.Mstm.If<T>(Metastorm.Runtime.Types.Check, T, T)' cannot be inferred from the usage. Try specifying the type arguments explicitly.

With no component set, natch. Luckily I recall this addition, and the problem above. I assume it is that. Nope, a whole new one. Can you figure it out? I mean, you've been given the error message, so it should be a cinch, surely? Well, I couldn't.

I tried the C# tertiary conditional operator (you non C# developers are going to have to get to know and love (or hate) these things, I can see that coming, I'm afraid - read on), like so:
EM_EquipmentFaultData1.FixedOn == Never()?CalculateDuration(EM_EquipmentFaultData1.ReportedOn, DateTime.CurrentDate, DateTimeUnits.Days):3


I get a more informative C# compilation error:
Quote:
Type of conditional expression cannot be determined because 'Metastorm.Runtime.Types.Integer' and 'int' implicitly convert to one another

Well whoopie do! So what should I do about that?

Well, because I'm a crusty old developer, and know a thing or two, such as
  1. what 'implicitly convert' actually means
  2. what problems that can cause for compilers
  3. and how to possibly avoid them
  4. and what casting is (and does)
I try the following:
EM_EquipmentFaultData1.FixedOn == Never()?CalculateDuration(EM_EquipmentFaultData1.ReportedOn, DateTime.CurrentDate, DateTimeUnits.Days):(Integer)3
And that flies like a bird.

Because I'm built like it, and becuase I know all you people out there in e-work world will need to know the answer, and even though Metastorm won't pay us to test their product, I try the following:
EM_EquipmentFaultData1.FixedOn == Never()?ProcessContext.FolderCategory:"some text"

Sure, enough, same error.

What about the same problem with the If() function? Let's try:
If(true,ProcessContext.FolderCategory,"some text")

Surely Metastorm would ship a product that caused such a simple statement  fail with such an inexplicable error message as: "The type arguments for method 'Metastorm.Runtime.Core.Mstm.If<T>(Metastorm.Runtime.Types.Check, T, T)' cannot be inferred from the usage. Try specifying the type arguments explicitly." and not even tell you what component is having the problem, would they?

Well I'm afraid they not only would, they did.

OK, so what have we learnt?

1. This is not a product for non-developers. Not even close. Not a chance. Analysts are going to be troubled in so many ways by problems such as these, and many others I have come across, and they are really C# issues, not Metastorm. It was a nice idea, but making it all C# has forced your users to become developers, it's as simple as that.

2. Metastorm did not consider (or test for) the problems inherent in this type of implicit conversion. The fact that the Text type does the same with the string type and causes the same bunch of errors, tells me once again that very little ...... (wait for it) ......
 Real World Testing ...... (ahhh, I feel better now) was done. I cannot imagine a real system where there was not a single condition returning either any Metastorm function returning an integer or string, and an literal integer or string. Not a single itty bitty one. Because that will always fail - every single time according this. This is a C# thing, not a Metastorm thing, so it will occur in every single instance. So not a single one was tested.

__________________
Post an example, and we will have a much better idea what the problem is. In about 90% of posts, the problem is one of communication. Examples bridge that gap.
0
Nappy

Avatar / Picture

Guru
Registered:
Posts: 1,087
Reply with quote  #2 

You take the blue pill and the story ends. You wake in your bed and believe whatever you want to believe. You take the red pill and you stay in C# land and I show you how deep the rabbit-hole goes. Remember -- all I am offering is the truth, nothing more.


__________________
Post an example, and we will have a much better idea what the problem is. In about 90% of posts, the problem is one of communication. Examples bridge that gap.

PS that's for V6/7 for V9 the problem is V9 at the moment ;)
0
BMellert

Guru
Registered:
Posts: 688
Reply with quote  #3 
I spent 2-1/2 days trying to find the cause of my issue.  I suspect, in this case, it was dynamic role logic.  I had
If(Conflict_AlarmData.HaveConflicts==true,ProcessContext.UserName,"")

when I changed it to
If(Conflict_AlarmData.HaveConflicts==true,ProcessContext.UserName,null)

this particular error went away.


 

However, I am still getting the following.  I have checked every conditional and if statement I can find in the process and cannot find a source.  How aggravating.

Quote:

The best overloaded method match for 'Metastorm.Runtime.Core.TextExpressionHelper.GetTextValue(Metastorm.Runtime.Types.Text)' has some invalid arguments
 
Argument '1': cannot convert from 'int' to 'Metastorm.Runtime.Types.Text'


0
Jerome

Avatar / Picture

Guru
Registered:
Posts: 5,507
Reply with quote  #4 
I just read through my initial post. It was quite funny! I must have had some serious venting to do.

You just have to take out each one until you find it. Painful, but bite that bullet...


__________________
Post an example, and we will have a much better idea what the problem is. In about 90% of posts, the problem is one of communication. Examples bridge that gap.
0
Fadilk

Member
Registered:
Posts: 25
Reply with quote  #5 
Responding to a very old post.  Had this issue today in version 9, after doing a serach I found this post.

What resolved the error for me was to add a .ToString() conversion to the then clause.

If(Conflict_AlarmData.HaveConflicts==true,ProcessContext.UserName.ToString(),"")
0
Jerome

Avatar / Picture

Guru
Registered:
Posts: 5,507
Reply with quote  #6 
Yes, we do a lot of that, especially when using "x ? y : z". In my opinion, be it ever so humble, the If() function should have been overloaded to accept all the different Metastorm types. That way, the conversion would have been implicit. It may have worse consequences, however, I am not certain without testing such a function.

Still, my initial concerns are still valid, in that non-developers are going to have a bad time with the product, at least initially and probably for ever. Having said that, we have produced a very workable approach that allows analysts (aka process designers) to use the product effectively while writing no code while developers write all the necessary code for them and deliver this in the Expression builder and Visual Script toolbox.

__________________
Post an example, and we will have a much better idea what the problem is. In about 90% of posts, the problem is one of communication. Examples bridge that gap.
0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:


Create your own forum with Website Toolbox!