1

I have a requirement to fetch CONTRACTLINE details based on the PO to which it has been mapped to it . So I have created an Object launch point on PO which will be triggered during "UPDATE" however the getMbo(0) on CONTRACTLINE is BLANK , I am not sure what is the issue as the count is >0 so ideally it should fetch the values.

userInfo=mbo.getUserInfo()
POContractNum = mbo.getString("CONTRACTREFNUM")
POContractRevNum = mbo.getInt("CONTRACTREFREV")
POContractOrgID = mbo.getString("ORGID")
PONum = mbo.getString("PONUM")
ContractSet = MXServer.getMXServer().getMboSet("CONTRACT",userInfo)
ContractSet.setWhere("CONTRACTNUM = '" + POContractNum + "' and STATUS=  'APPR'  and ORGID = '" + POContractOrgID + "'")
ContractSet.reset()
Contract = ContractSet.getMbo(0)
print 'Contract number', ContractSet.getMbo(0).getString("CONTRACTNUM")
ContractLineSet = MXServer.getMXServer().getMboSet("CONTRACTLINE",userInfo)
ContractLineSet.setWhere("CONTRACTNUM = '" + POContractNum + "' and  LINESTATUS = 'APPR'  and ORGID = '" + POContractOrgID + "'")
ContractLineSet.reset()
print " Contract Line Where : " + ContractLineSet.getWhere()
print " Contract Lines Selected = " + str(ContractLineSet.count())
print " mbo contract line contract num ",   ContractLineSet.getMbo(0).getString("CONTRACTNUM")
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Contract number PCR1214
Contract Line Where : CONTRACTNUM = 'PCR1214' and LINESTATUS = 'APPR'  and ORGID = 'XXXX'
Contract Lines Selected = 1
mbo contract line contract num 
Jeroen
  • 1,638
  • 3
  • 23
  • 48
max092012
  • 365
  • 1
  • 5
  • 25
  • I would call getMbo(0) before calling count() – Preacher Aug 31 '16 at 15:53
  • I would also use getMboSet() on instances of Mbo, not on instances of MXServer, to avoid the memory leaks present in the code given. – Preacher Aug 31 '16 at 15:54
  • I tried using getMboSet() with relationship however it didnt work... same blank value . I shall try getMbo(0) before calling count() however I am not sure what different it makes. – max092012 Aug 31 '16 at 16:44
  • From the Javadocs on MboSet.setWhere, "The Where clause takes effect when the MboSet is reset and a record is fetched." As far as I know, calling count() does not cause a record to be fetched, meaning that calling it after calling setWhere() and reset() will give you meaningless results. – Preacher Aug 31 '16 at 16:53
  • No it didnt work , below is what I used ContractLineSet = MXServer.getMXServer().getMboSet("CONTRACTLINE",userInfo) ContractLineSet.setWhere("CONTRACTNUM = '" + POContractNum + "' and LINESTATUS = 'APPR' and REVSTATUS= 'CHANGED' and ORGID = '" + POContractOrgID + "'") #ContractLineSet.reset() print " mbo contract line contract num", ContractLineSet.getMbo(0).getString("CONTRACTNUM") print " Contract Line Where : " + ContractLineSet.getWhere() print " Contract Lines Selected = " + str(ContractLineSet.count()) – max092012 Sep 01 '16 at 03:05
  • Can you confirm the queries being executed against the database? Set the Log Level to INFO for the sql / CONTRACTLINE logger. Once you get the query out of the logs, run it for yourself and see what comes back. – Preacher Sep 01 '16 at 23:46
  • Also, you could show yourself whether ContractLineSet.getMbo(0).toBeAdded() returns true or false. I don't know why it would be true, but something isn't right and this is something we can check. – Preacher Sep 01 '16 at 23:48
  • Yes the query is correct , select * from contractline where contractnum='XXX' and linestatus='APPR' and REVSTATUS='CHANGED' and orgid='YYY' . Additionally when I tried to print ContractLineSet.getMbo(0).toBeAdded() returns BLANK ( neither TRUE or FALSE). – max092012 Sep 04 '16 at 18:13
  • you're sure there are no additional errors in the systemout.log or systemerr.log? – Jeroen Sep 05 '16 at 12:49
  • any luck with the logfiles? – Jeroen Sep 07 '16 at 15:10
  • 1
    The link that you had shared worked .. it was some other script on CONTRACTLINE object which was causing the problem and when I deactivated that it did worked. Thanks a lot for your help!! – max092012 Sep 09 '16 at 15:05

1 Answers1

0

I think I ran into a very similar problem earlier. Please review the answer here: https://stackoverflow.com/a/27423780/1341373

Community
  • 1
  • 1
Jeroen
  • 1,638
  • 3
  • 23
  • 48
  • I remember seeing this before posting this question however it didn't work. I have added the code again and let me know if I have made any mistake . – max092012 Sep 05 '16 at 14:43
  • `setWhere = "CONTRACTNUM = '" + POContractNum + "' and LINESTATUS = 'APPR' and REVSTATUS= 'CHANGED' and ORGID = '" + POContractOrgID + "'" print 'setwhere' , setWhere ilSet = mbo.getMboSet("$ContractLineRelationship", "CONTRACTLINE", setWhere) print 'set', ilSet print 'first mbo value', ilSet.getMbo(0) ilMbo = ilSet.moveFirst() print ' first value', ilMbo print 'contractnum', ilSet.moveFirst().getString("CONTRACTNUM")` – max092012 Sep 05 '16 at 14:51
  • `+++++++++++++++++++++++++++++++++ setwhere CONTRACTNUM = 'C1234' and LINESTATUS = 'APPR' and REVSTATUS= 'CHANGED' and ORGID = 'XXXXX' set psdi.app.contract.ContractLineSet@4a944a94 first mbo value ` – max092012 Sep 05 '16 at 14:53
  • so it does return an object... did it print the contractnum as well? Please note that ilSet.getMbo(0) does not return a value, but an object. This will only work of the ilSet is not empty. – Jeroen Sep 05 '16 at 15:09
  • `print 'first mbo value' , ilSet.getMbo(0)` is BLANK which i don't think is correct. it should have printed the value of the object . Also if you look at my second comment then nothing has got printed after " first mbo value" . So contractnum is BLANK – max092012 Sep 05 '16 at 15:16