This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - Method not work properly Every Time

Pankaj Thakur - Saturday, April 20, 2013 4:06 AM:

Hello Community,
      I create a server side method in C# for my client for Core Coil Assembly and use on "On After update" event but an issue raised. When I run method it show the result.

But when I update my itemtype some times it gives correct value, some time it  give old value and some time it give garbage value. but when I updated it 2 or 3 times it gives correct value . I don't understand what is the problem . when I restart my innovator it give correct value on 1st attempt . I also try to do page refresh before save and updated item type. but its not working.

I also create some more method but I don't face that type of problem before.

In this method I used "

Convert

.ToDecimal(this.getProperty("property_name"));

 

" multiple loops for diffrent condition.

I think the method was correct becouse it gives correct value when  update it around  2 or 3 times.

Please give me some idea that how can I resolve this problem.

its very important for me .


Thanks & Regard
Pankaj Thakur



Brian - Friday, May 3, 2013 12:34 PM:

Hi Pankaj;

Not sure that I really understand what is going wrong here.

Convert.ToDecimal( ) should always work.

However:

this.getProperty("property_name");

may not give you the results you are expecting if there is no value in "property_name".

You should consider using:

this.getProperty("property_name","default value");

which will return the "default value" if there is no value in the "this" object for the property you are searching for.

So in your example I would use:

Convert.ToDecimal(this.getProperty("property_name","0"));

Hope this helps,

Brian.



Pankaj Thakur - Saturday, May 4, 2013 6:48 AM:

Hello Brian Sir,
           Thanks for the reply.
            Convert.ToDecimal work Properly.

Actually the Problem is that when I update the Itemtype and save and unlock it for update (because of "on after Update" Event). Sometime it doen't give correct value but when i again save and update without any change it works properly and the problem is in a proper field (Winding Completed). Other Field i.e (Total LV, Total HV, Remain LV, Remain HV, Total Spacer, Total Stick, Total Block , etc) works fine.

I attached a word file which contain the screenshot of the actual problem please checked it out sir.

Link Given below:




Thanks & Regards
Pankaj Thakur



Eric Domke - Monday, May 6, 2013 9:04 PM:

Because a relationship can be added without an update to the parent item type, you want to run your server event onAfterAdd and onAfterUpdate of the relationship item type (Winding Status) instead of onAfterUpdate of the parent item type (Core Coil Assembly).  You will need to change your method because the context item will be different (the relationship item instead of the parent item), but you will get much more consistent and reliable results.