Verifying a stock transfer and and activation  Topic is solved

Discussions relating to Jiwa 7 plugin development, and the Jiwa 7 API.

Verifying a stock transfer and and activation

Postby indikad » Wed Dec 16, 2015 2:38 pm

The jiwa 7 Stock transfer object has a Save method that is a sub rather than the function that was in 6513 ( SaveRecord)
in 6513 I was able to verify if the stock transfer was created by checking the return value of the SaveRecord method.
How do I do this in Jiwa7 object ?

similarly I need to verify the Activation was successfull or not too (ActivateRecord method )


related thread -
viewtopic.php?f=27&t=491&p=1678#p1678
indikad
Frequent Contributor
Frequent Contributor
 
Posts: 182
Joined: Thu Jun 18, 2009 1:14 pm
Topics Solved: 2

Re: Verifying a stock transfer and and activation

Postby Scott.Pearce » Wed Dec 16, 2015 2:55 pm

Wrap your call to Save() in a try catch block thus:

Code: Select all
Try
  myStockTransferObject.Save
Catch ex as Exception
  msgbox(ex.Message) 'Or you could log to the eventlog, a file, do nothing, whatever you like.
End Try


The Catch block is only entered if there is a problem inside the myStockTransferObject.Save method. Our methods will always Throw() if there is a problem. This is a fundamental construct in .Net, so I recommend you read up here.
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 765
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 230

Re: Verifying a stock transfer and and activation

Postby indikad » Wed Dec 16, 2015 3:26 pm

thanks Scott. I already use try - Catch.
I was just wondering if there was a possibly of getting a return value thats all.

all good.
indikad
Frequent Contributor
Frequent Contributor
 
Posts: 182
Joined: Thu Jun 18, 2009 1:14 pm
Topics Solved: 2

Re: Verifying a stock transfer and and activation  Topic is solved

Postby Mike.Sheen » Wed Dec 16, 2015 5:09 pm

indikad wrote:I was just wondering if there was a possibly of getting a return value thats all.


No - subs don't return a value only functions can.

The old way might have had a return code of an integer which was an enumerated type - 0 = failure, -1 = success, 1 = cancelled.

The new pattern is to throw an exception on error, and throw an exception of type clientcancelled on cancellation.

So, you can emulate the old behaviour in your invocation to the sub:

Code: Select all
Dim returnValue as Integer = -1 ' Default to success
Try
    myStockTransferObject.Save
Catch cancelledEx As JiwaApplication.Exceptions.ClientCancelledException
    returnValue = 1
Catch ex As System.Exception
    returnValue = 0
End Try


Personally, I wouldn't do that.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 1 guest