cherokee
17th July 2007, 20:46
Hello everyone,

I added a new field(aprv.cmc, tcyesno type) to table tiedm100. So I did it on the form Maintain Engineering Revisions.

I can update effective date or release the revision or reset release revision. But when I want to update the field I added myself, it doesn't work.


... else
if updt.date = tgyenox.yes then
stpapi.put.field("tiedm1101m000","tiedm100.indt",str$(rev.indt))
endif
if updt.aprv = tgyenox.yes then
stpapi.put.field("tiedm1101m000","tiedm100.aprv.cmc",str$(etol(aprv.cmc)))
endif
if updt.date = tgyenox.yes or updt.aprv = tgyenox.yes then
stpapi.update("tiedm1101m000",true,error.message)
else ....


Any idea what could be the problem?

Thanks,

Carlos
:confused:

mark_h
17th July 2007, 21:38
I can only relate one experience I had - on maintain purchase orders we added a new table field on the form. Using API commands I could not update the field. To work around this I just did a direct table update.

Do you have the session source code so you can debug it to see what the new field contains when it hits the update? Or if maybe something else is happening. From just looking at your code it should work.

Another thing to try is to do the update twice for this field. I have seen this work before also.

cherokee
19th July 2007, 17:05
Hi Mark,

Thanks for you advice... the update twice unfortunately did not work.

Now, I can Reset Release Revision but I can’t Release it. The only difference in the code is the user’s option number on function (stpapi.application.option("tiedm1101m000",1, 1, error.message)) that is either 1 or 2. Can’t update anything either. Session tiedm1101m000.

Do you know what is the difference between stpapi.browse.view and stpapi.browse.set . I am using the later. Once I am at the record I want to update, I can get values from any field I want but when it comes to change/update values, does nothing the API’s!

Any help is welcome.

Carlos

cherokee
19th July 2007, 20:38
Hello again,

after further investigation, I found that when I use the stpapi.browse.set("tiedm1101m000","next.set") command and find the record I want to update among several revisions. Before I update, I also check the values on the record found are the ones corresponding to the one I want to change; Then I put the new values with stpapi.put.field (i.e. "new description") ("tiedm1101m000","tiedm100.dsca",t.dsca) then I issue stpapi.update("tiedm1101m000",true,error.message) and stpapi.end.session("tiedm1101m000"). The record that gets updated is the first record found in the revisions, no the one I found with the browse.set command!

Just to clarify ... I have revision A,B and C. I navigate from A to C with browse.set command, when I find C I try to update C and the one that gets updated is A!

stpapi.browse.set, set the record found as current, isn't?

Why will it update the very first record of the set of revisions if I navigate with the browse.set command?

Thanks in advance,

Carlos

mark_h
19th July 2007, 21:03
I think Al Smith put it best here (http://www.baanboard.com/baanboard/showthread.php?t=5502).
I typically use stpapi.browse.set to roll through the record. Maybe if you post your code someone will see something. Of course I do not know how that session works.

cherokee
6th August 2007, 17:14
Ok.. here is how I made it work.


.....
stpapi.put.field("tiedm1101m000","tiedm100.eitm",i.eitm)
stpapi.put.field("tiedm1101m000","tiedm100.indt",str$(0))
stpapi.put.field("tiedm1101m000","tiedm100.revi","")
ret = stpapi.change.view("tiedm1101m000")
.....
while true
stpapi.get.field("tiedm1101m000","tiedm100.eitm",t.item)
stpapi.get.field("tiedm1101m000","tiedm100.revi",t.revi)
stpapi.get.field("tiedm1101m000","tiedm100.indt",t.s.indt)
if t.item <> i.eitm then
stpapi.end.session("tiedm1101m000")
return
endif
if t.revi <> i.revi then
stpapi.browse.view("tiedm1101m000","next.set")
else
stpapi.put.field("tiedm1101m000","tiedm100.eitm",t.item)
stpapi.put.field("tiedm1101m000","tiedm100.indt",t.s.indt)
stpapi.put.field("tiedm1101m000","tiedm100.revi",t.revi)
ret = stpapi.find("tiedm1101m000") |with these four lines above I handled to update the rev/record I want.
|I know it doesn't look pretty but it works.
break
endif
endwhile .....

stpapi.put.field("tiedm1101m000","tiedm100.indt",str$(rev.indt))
stpapi.put.field("tiedm1101m000","tiedm100.aprv.cmc",str$(etol(aprv.cmc)))
stpapi.update("tiedm1101m000",true,error.message)
stpapi.end.session("tiedm1101m000") ......



Thanks for all your help.

Carlos
:cool: