Page 1 of 1

SalesQuoteObject.ReadRecord use

PostPosted: Fri Sep 10, 2010 6:51 pm
by dallen
Hi,

I have used http://jiwa.net/forums/viewtopic.php?f=14&t=119 as a base, however I did this in c#. Unfortunately I cannot get readrecord to work correctly. Because c# (I'm on 3.5) does not support optional parameters I cannot seem to use readrecord only providing the first three arguments. I normally use reflection's Missing.Value but in this case it does not work.

Beyond an explanation for why this is... What does "filterstring" represent? What is a legit filterstring that I could pass? I pass false for drilldown..

I receive the error:
Error On Fetch : clsRecordSet.FetchRow - No Data Found

If I could get some help with this it would be great. I have tried multiple "solutions":
Empty string as per below
null
Missing.Type
Reflection's MethodInfo (although I could not invoke as I was receiving null back when searching for readrecord..)

Thanks very much.

Code: Select all
string connstr = @"blahblah";
           
            JiwaODBC.database db = new JiwaODBC.database();
            JiwaCommonLib.stdFunctions commlib = new JiwaCommonLib.stdFunctions();
            JiwaLib.StdFunctions jiwalib = new JiwaLib.StdFunctions();
            JiwaSysProfile.clsSysProfile profile = new JiwaSysProfile.clsSysProfile();
           
            db.ConnectionDetails = connstr;
            db.IniFile = @"blahblah";
            profile.Load(db.IniFile);

            DateTime date = new DateTime();
            bool changepass = false;
            if (db.MakeConnections(0))
            {
                db.DoLogOn("blahblah", "blahblah", ref changepass, ref date);
            }
            clsSalesQuote sq = new clsSalesQuote();
            sq.Database = db;
            sq.JiwaCommLib = commlib;
            sq.JLib = jiwalib;
            sq.SystemProfile = profile;

            sq.Setup();
            sq.ReadDefaultBranch();

            sq.ReadRecord(0, 0, "A1C97E5491784DE89F0E", "", false);

Re: SalesQuoteObject.ReadRecord use

PostPosted: Wed Sep 15, 2010 6:11 pm
by dallen
Hi,

I ended up using string.empty and false for my values, however I still have no record found.

I note that the original thread also had this problem, so i don't think this is a language problem but something related to the code.

Can someone please have a look at either my code or the original vbscript and advise if something is wrong/missing? That would be great.

Re: SalesQuoteObject.ReadRecord use

PostPosted: Mon Sep 20, 2010 6:55 pm
by Mike.Sheen
dallen wrote:Hi,

I ended up using string.empty and false for my values, however I still have no record found.

I note that the original thread also had this problem, so i don't think this is a language problem but something related to the code.

Can someone please have a look at either my code or the original vbscript and advise if something is wrong/missing? That would be great.


The System Profile object you create and pass to the quote object hasn't been told to load an profile.xml, so it doesn't know which logical warehouse it's context is in. All documents like quotes are partitioned into a logical warehouse, so when doing any sort of read it needs to know the logical warehouse.

You can verify this by checking the return value the ReadRecord returned : if 0 then an error occurred, and check the ErrorString property to reveal the cause - if it is "No data found" then my assertion above is correct.

If this is the case, try the following code after you instantiate the system profile object :
Code: Select all
SystemProfile.Load("C:\Program Files\Jiwa Financials\Jiwa\jiwa.xml")

Re: SalesQuoteObject.ReadRecord use

PostPosted: Tue Sep 21, 2010 4:18 pm
by dallen
Hi Mike,

Thanks for the response. I had a look at my code and I believe I am doing this - the line which is profile.load(db.inifile) directly after setting the inifile. Is there anything else I am missing?

Re: SalesQuoteObject.ReadRecord use

PostPosted: Fri Sep 24, 2010 7:36 pm
by Mike.Sheen
dallen wrote:Hi Mike,

Thanks for the response. I had a look at my code and I believe I am doing this - the line which is profile.load(db.inifile) directly after setting the inifile. Is there anything else I am missing?


Not sure - certainly you should be examining the return code DoLogon returns, if it is 0, then you should examine the error properties (errorstring / message and error module).

Re: SalesQuoteObject.ReadRecord use

PostPosted: Mon Sep 27, 2010 11:52 am
by dallen
Hi Mike,

It turned out to be the logical warehouse not being set - after adding that it worked fine.

For future people looking at this post:
Code: Select all
if (db.MakeConnections(0))
            {
                db.DoLogOn("user", "password", ref changepass, ref date);
            }

becomes
Code: Select all
if (db.MakeConnections(0))
            {
                db.DoLogOn("user", "password", ref changepass, ref date);
            }
db.CurrentLogicalWarehouseID = "logicalid";

Re: SalesQuoteObject.ReadRecord use

PostPosted: Mon Sep 27, 2010 10:40 pm
by Mike.Sheen
dallen wrote:Hi Mike,

It turned out to be the logical warehouse not being set - after adding that it worked fine.

For future people looking at this post:
Code: Select all
if (db.MakeConnections(0))
            {
                db.DoLogOn("user", "password", ref changepass, ref date);
            }

becomes
Code: Select all
if (db.MakeConnections(0))
            {
                db.DoLogOn("user", "password", ref changepass, ref date);
            }
db.CurrentLogicalWarehouseID = "logicalid";


Excellent - thanks for posting back your solution!