Baanboard.com

Baanboard.com (http://www.baanboard.com/baanboard/index.php)
-   AFS/DDC/OLE: Function servers (http://www.baanboard.com/baanboard/forumdisplay.php?f=59)
-   -   Handle STD Question (http://www.baanboard.com/baanboard/showthread.php?t=68694)

frenny 3rd March 2016 14:10

Handle STD Question
 
Hello ,

My Requirement is to Insert Label in STD Label Session ttadv1140m000,
so I have Write AFS for that session .It is working for New Label with new desc .but if i have insert new Label for Which desc is already Present in some existing session, it will ask one question in std "ttadv11403" , but that Question is not handle in my AFS .I have Tried Question Code at Diffrent Place but still not working for new DESC

|| AFS

stpapi.put.field("ttadv1140m000", "ttadv140.clan", cust.clan)
stpapi.put.field("ttadv1140m000", "ttadv140.cpac", cust.cpac)
ret = stpapi.change.view("ttadv1140m000", err)

ret = stpapi.synchronize.dialog("ttadv1140m000", "add", err)
if ret = 1 then
stpapi.enum.answer("ttadv1140s000", "ttadv11403", ttyeno.yes )
stpapi.put.field("ttadv1140s000", "ttadv140.vers", cust.vers)
stpapi.put.field("ttadv1140s000", "ttadv140.rele", cust.rele)
stpapi.put.field("ttadv1140s000", "ttadv140.cust", cust.cust)

stpapi.put.field("ttadv1140s000", "ttadv140.zc_cont", str$(etol (ttadv.cont.general)))
stpapi.put.field("ttadv1140s000", "ttadv140.desc", str$(trim$(new.label)))
stpapi.put.field("ttadv1140s000", "ttadv140.clab", trim$(f.prefix & str$(get.count)))
stpapi.enum.answer("ttadv1140s000", "ttadv11403", ttyeno.yes )

ret = stpapi.insert("ttadv1140s000",true, err)
if ret then
stpapi.get.field("ttadv1140s000", "ttadv140.desc", get.desc)
stpapi.get.field("ttadv1140s000", "ttadv140.clab", get.clab)
endif
stpapi.end.session("ttadv1140s000")
stpapi.end.session("ttadv1140m000")
endif

I have Also done this by Using DAL - but it will give language error in DAL - i have use 2 as language

switch.to.company(000)
dal.new.object("ttadv140")
dal.set.field("ttadv140.clan", "2")
dal.set.field("ttadv140.cpac", cust.cpac)
dal.set.field("ttadv140.vers",cust.vers)
dal.set.field("ttadv140.rele",cust.rele)
dal.set.field("ttadv140.cust",cust.cust)
dal.set.field("ttadv140.zc_cont",ttadv.cont.general)
dal.set.field("ttadv140.desc",new.label)
dal.set.field("ttadv140.clab", f.prefix)

if dal.save.object("ttadv140") = 0 then
commit.transaction()
else
dal.get.error.message(err)
mess("ltanystr",0,err)
endif

Thank you
Frenny K

Ajesh 3rd March 2016 14:41

Hi Frenny

There is an AFS section and that section was most revelant for your question.

Anyways.What is the exact question that is asked and what is the default answer in the question?Regarding this AFS functionality, there is a condition that states

Code:

This function must only be used for questions for which the default answer in the session must be overruled.
Perhaps the default answer is Yes .. It could be a small possibility.

mark_h 3rd March 2016 15:53

Moved to correct forum.

I had this happen in one standard baan session. No matter what I tried it would not work with the stpapi commands. Eventually I just changed the default answer on the question. Not sure that will work for you since this is a tools question. Also confirm the domain is correct(and not tcyesno.yes).

Another option - is before adding, check if present, if present delete it and re-add the record from scratch. A lot more coding but another possibility.

bhushanchanda 3rd March 2016 16:31

Hi,

Surprisingly, your code works just fine for me.

Though, I would suggest to put the stpapi.enum.answer() before using any put() functions.

Code:


stpapi.enum.answer("ttadv1140s000", "ttadv11403", ttyeno.yes )
stpapi.put.field("ttadv1140m000", "ttadv140.clan", cust.clan)
stpapi.put.field("ttadv1140m000", "ttadv140.cpac", cust.cpac)
ret = stpapi.change.view("ttadv1140m000", err)

ret = stpapi.synchronize.dialog("ttadv1140m000", "add", err)
if ret = 1 then

stpapi.put.field("ttadv1140s000", "ttadv140.vers", cust.vers)
stpapi.put.field("ttadv1140s000", "ttadv140.rele", cust.rele)
stpapi.put.field("ttadv1140s000", "ttadv140.cust", cust.cust)

stpapi.put.field("ttadv1140s000", "ttadv140.zc_cont", str$(etol (ttadv.cont.general)))
stpapi.put.field("ttadv1140s000", "ttadv140.desc", str$(trim$(new.label)))
stpapi.put.field("ttadv1140s000", "ttadv140.clab", trim$(f.prefix & str$(get.count)))

ret = stpapi.insert("ttadv1140s000",true, err)
if ret then
stpapi.get.field("ttadv1140s000", "ttadv140.desc", get.desc)
stpapi.get.field("ttadv1140s000", "ttadv140.clab", get.clab)
endif
stpapi.end.session("ttadv1140s000")
stpapi.end.session("ttadv1140m000")
endif


frenny 4th March 2016 06:16

Thank you very much bhushanchanda sir , your code is working.. :)

Frenny

mark_h 4th March 2016 16:15

Now that just does not make sense to my 4c4 mind. In 4c4 I just need to answer the question before any action is executed(like a save, delete, etc). Is this another ln "feature"? :)

bhushanchanda 4th March 2016 20:42

Mark,

Fortunately, AFS is one of the few things which hasn't changed in LN or the newer 10.4 versions. :)

The reason why it works is, the question pops up when we put the Description field value and not when the record is saved.

Following your suggestion on this thread I always prefer to answer the question before starting stapi.put.field().

Marek_C 13th March 2017 10:18

Anyone got a clue, why DAL doesn't work?

mark_h 20th March 2017 00:58

Dal does not work in what way? I think is the preferred method over AFS for LN.


All times are GMT +2. The time now is 01:27.


vB.Sponsors
©2001-2017 - Baanboard.com - Baanforums.com