hi,
sorry, i couldn't write in German, aber ich wolle Deutsch sprechen
I try to change Material ID field with the Material Type with a number incremented, for example; if I change the material type as 'brass', Material ID should be 'brass-1', 'brass-2', so on, when I change the material type as 'paper', it should be 'paper-1' and so on.
Firstly I define a variable as CN_COUNTER, this variable should be initialized with ADD operation, then should be incremented with UPDATE operation. Here is the code for UPDATE operation (I couldn't solve incrementing yet) ;
Function UpdateMaterialID(ApplHndl As Long,OpStr As String, _
FirstPar As Long,SecondPar As Long,ThirdPar As Long ) As Integer
Dim Session As SmSession
Set Session = SCREXT_ObjectForInterface(ApplHndl)
Dim RecListIn As Object
CONV_RecListToComRecordList FirstPar,RecListIn
Dim RecListOut As Object
CONV_RecListToComRecordList ThirdPar, RecListOut
Dim RecordIn As Object
Set RecordIn = RecListIn.GetRecord(0)
Dim ObjectStore As ISmObjectStore
Set ObjectStore = Session.ObjectStore
Dim SourceObject As ISmObject
Set SourceObject = ObjectStore.ObjectFromData(RecordIn, True)
Dim AttributeName As String
Dim SourceAttribute As ISmClassAttribute
Dim SourceAttributes As ISmClassAttributes
AttributeName = "CN_MATERIAL_TYPE"
Set SourceAttributes = SourceObject.Attributes
Set SourceAttribute = SourceAttributes.ItemByName(AttributeName)
Dim LookupValue As Long
Dim LookupClassId As Long
Dim LookupObject As ISmLookUpObject
LookupValue = SourceObject.Data.ValueAsInteger(AttributeName)
LookupClassId = SourceAttribute.ReferencedClassId
Set LookupObject = ObjectStore.GetSmLookUp(LookupClassId, LookupValue)
RecListOut.AddHeader "CN_ID",20,1
RecListOut.ValueAsString ("CN_ID", 0) = LookupObject.DisplayName
CONV_ComRecListToRecordList RecListOut,ThirdPar
End Function
CN_ID is the attribute for Material ID.
I can easily get the display name of the lookup table in UPDATE operation, but not in ADD operation, when I try to use the same code, the error is;
Error No: 02101
Internal Error. Method 'SetupFromRecord' requires attribute 'OBJECT_ID' in the input record.
any advice or solution for ADD operation and incrementing the number will be highly appreciated, thanks for your help.
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP