help_ln
23rd February 2007, 10:30
Hi,

I am trying to find an Item through AFS in Maintain Lots session.
If the item does not exist, i dont't get an find error message, instead it goes to the next record.

How to resove this ????

Thanks in advance.

jp.aalders
23rd February 2007, 10:53
Check the item you're looking for with the item found by AFS. If they are not the same you don't have a "match" en you can execute further actions.

Good Luck!:)

help_ln
23rd February 2007, 11:09
Hi,

So when there is no match, there is no error msg coming which should be coming.

Could u also tell how to insert Group through AFS.

Thanks

george7a
23rd February 2007, 13:06
Hi,

You can also check if the item exists using regular SQL syntax.

- George

mark_h
23rd February 2007, 14:12
Is you are using stpapi.find just check the return code - 0 means no record found and 2 means a record other than the one requested was returned. So if it does not equal 1 you did not find a record.

help_ln
23rd February 2007, 14:47
Yes.. i checked thru regular SQL syntax that the item does not exits as well as through the return value.

Now i have to insert the this item which does not exists .
Not able to find how to insert a group through AFS.

Pls help

Thanks

mark_h
23rd February 2007, 14:56
Here is a simple little example:

function add.builditem()
{
stpapi.put.field( "tipgc8100m00b", "tipgc800.cprj", project )
e = stpapi.change.view( "tipgc8100m00b" )
stpapi.put.field( "tipgc8100m00b", "tipgc800.cprj", project )
stpapi.put.field( "tipgc8100m00b", "tipgc800.butm", builditem )
stpapi.put.field( "tipgc8100m00b", "tipgc800.dsca", description )
stpapi.insert( "tipgc8100m00b", 1, errmsg)
|021902 Skip records already exist. This means the build item
| was already added.
if(strip$(errmsg)<>"" and pos(errmsg,"Record already exists")=0) then
mess.1= "1." & builditem & " " & errmsg
write.error(mess.1)
else
mess.1="1. Build item added. " & builditem
endif
display("mess.1")
stpapi.end.session( "tipgc8100m00b" )
}

In this case I do not if check to see if the group(or view fields) exists. I just insert the record and ignore error where it says duplicates exists. As a matter of fact I could completely remove the error checks in this routine. If this is related to the find question you may want to try change.view command first and see what it returns. Which session are you working with? I am on 4c4 and your profile says LN and there can be differences.

ahmer91
24th February 2007, 09:12
i have got Complete AFS Guide , if you require please send me email to faisaljk@hotmail.com