tmannais
16th January 2018, 11:18
Hi,

I am having a problem about AFS.
I use stpapi.put.field() to put values into the mandatory fields.
After that, I use stpapi.insert() to insert the record.
I normally do something like this and all the works I have done can perform just fine.
However, this session (tfacr1110s000) doesn't.
After running the AFS code, it gives error pointing that a mandatory field is missing even though I just put it in before the insert line.
After a while of investigating, I suspect that this stpapi.insert() clears the field itself and then gives error because it cannot insert since the field (it just cleared) is empty. I think because a field here has a default value for the field to be empty and it overwrites after the AFS had just finished its script.
Am I misunderstanding anything?
If not, is there a solution for this issue?
Please help.
Thanks in advance.

Regards,
Thana

mark_h
16th January 2018, 14:48
Moved to the correct forum. Hard to say exactly what might be happening but it sounds reasonable. In a couple of situations like this our solution was to use qkey to modify the source code - assuming you do not own source. Other times I have done a save followed by an update. I think even in one place I had to do an update with the update flag set to false before I could get something like an insert to work. Not familiar with LN or that session so just relating some of the stuff I have done in 4c4.

tmannais
17th January 2018, 04:05
I will try what you suggested and let you know if the solutions work.
By the way, please tell me more about QKEY and how can I get it?

Regards,
Thana

tmannais
17th January 2018, 13:02
I tried your solutions except QKEY and all of them did not work.
Using Save and then Update results in "Command Disabled".
Using Update with flag set to false and then Insert results in the same error as I had before -- the field is empty.
I really want to try QKEY. Please advice.

Regards,
Thana

mark_h
17th January 2018, 14:20
Are you on LN? See this thread where they got it to work http://www.baanboard.com/baanboard/showthread.php?t=67971&highlight=tfacr1110s000.

Qkey is no longer supported or available. Qkey is basically a source extender like what ~vamsi posted in http://www.baanboard.com/baanboard/showthread.php?t=559 the code and utilities forum.

tmannais
18th January 2018, 12:42
I explore every reply in the link you gave me. I came up with a method to stpapi.put.field() only on tfacf200.itbp and then insert. It can actually insert the record to the database. After that, I put other fields in and update, and I found that field tfacr200.dued causes the issue. So, I put in every field other than tfacr200.dued and it works just fine now. I will try to update the field later but it is easier than before now because at least it is inserted into the database.
Thank you so much for your help.

Regards,
Thana

mark_h
18th January 2018, 14:26
Glad you found the solution. I know I do that exact same thing on my PO session - I create the PO then go back and update 1 field (and I actually use a select/update) to get it updated. For some reason it would never update thru stpapi - I think it was buyer.