Order of events in 8.2 sr-04

Probably one for Conrad.

Have a sales validation script that works fine in 7.5 but fails sometimes in 8.2 due to the changes in the event system.

When creating a new sale the OncurrentSaleIdentityChanged event is coming after the OnEditSaleClicked event.

This seems a bit backwards. The script is then validating against the old current sale identity and even if this validation sets the validation message to block save is then being cleared by the system when the Identity changes.

I had purposely avoided the OnIdentityChanged event so that the script wouldn't fire repeatedly when browsing a list of sales.

The OnPersonFieldsChanged event is also curious as no person is selected. I would have expected OnSaleFieldsChanged.

 

RE: Order of events in 8.2 sr-04

Hei Jason,
I will have a look at this a.s.a.p.
I am afraid that the sequence of events is particularly messy, dificult to control, in Sale. The GUI shows clear evidence of this by flashing controls.
The order between OnCurrentSaleIdentityChanged (model message) and OnEditSaleClicked (a gui message) is not something we are very concerned with. This can easily change from one version to another. May be it shouldn't! 
I'll have to get back to you on this.
I think perhaps you should register a issue for this.

Also, if you can show us your script or atr least the main parts, that will help us get a better idea.

Conrad

I get this when I click New sale with our latest 8.3:

1: 09:42:57:611 OnEditSaleClicked (1)
2: 09:42:57:628 OnCurrentSaleIdentityChanged (1)
3: 09:42:57:634 OnCurrentQuoteIdentityChanged (1)
4: 09:42:57:638 OnCurrentQuoteVersionIdentityChanged (1)
5: 09:42:57:644 OnCurrentQuoteAlternativeIdentityChanged (1)
6: 09:42:58:252 OnCurrentSaleDefaults (1)

Af: Conrad Weyns 15. maj 2018

RE: Order of events in 8.2 sr-04

The main issue is that I can no longer recieve the currentsale.contact.identity value as there is no event fired when this finally changes after the new sale opens.

The onsaleeditclicked event still has the sale.contact.identity of the previous currentsale.

The onsaleidentitychanged event returns sale.contact.identity = 0

There is no event when the sale.contact.identity value changes to that of the contact we inititate the new sale from.

Af: Jason Tiler Broad 15. maj 2018

RE: Order of events in 8.2 sr-04

Hi Conrad,

Do you have the syntax for being able to react to the OnPersonFieldsChanged event?

As this is the last event fired in the given situation I might be able to work around it if I ca nreact to that event.

Af: Jason Tiler Broad 15. maj 2018

RE: Order of events in 8.2 sr-04

And the script looks like this:

 
Dim Result: Result = 0
Dim ConCat: ConCat = 2 '* "Emne"
Dim SumArray: SumArray =  Array("udsalesmall.LONG01","udsalesmall.LONG02","udsalesmall.LONG03","udsalesmall.LONG04","udsalesmall.LONG05","udsalesmall.LONG06","udsalesmall.LONG07","udsalesmall.LONG08","udsalesmall.LONG09","udsalesmall.LONG10","udsalesmall.LONG11","udsalesmall.LONG30")
Dim CheckFldArray: CheckFldArray = Array("sale.CONTACT_ID","sale.SALETYPE_ID","sale.ACTIVELINKS")
Dim FordelArray : FordelArray = Array("udsalesmall.LONG45","udsalesmall.LONG32","udsalesmall.LONG33","udsalesmall.LONG34","udsalesmall.LONG35","udsalesmall.LONG36","udsalesmall.LONG37","udsalesmall.LONG38","udsalesmall.LONG39","udsalesmall.LONG40","udsalesmall.LONG41","udsalesmall.LONG42","udsalesmall.LONG43","udsalesmall.LONG44")­
Dim Montharray : MonthArray = Array("udsalesmall.LONG18","udsalesmall.LONG19","udsalesmall.LONG20","udsalesmall.LONG21","udsalesmall.LONG22","udsalesmall.LONG23","udsalesmall.LONG24","udsalesmall.LONG25","udsalesmall.LONG26","udsalesmall.LONG27","udsalesmall.LONG28","udsalesmall.LONG29")
Dim AndenBetalerRel: AndenBetalerRel = 17
Dim CAOrderFlag: CaOrderFlag = """SuperOffice:13"""
Dim Aarsaftale : Aarsaftale = 9
Dim enTableProjType: enTableProjType = 85
Dim ValResult : ValResult = 0
Dim Fsum : Fsum = 0
Dim Msum : Msum = 0
Dim TCall : TCall = 0

'* ---------------- Not part of original script added as attempt to find error ----------------------------
Sub OnPersonFieldsChanged()
somessagebox "Person Fields changed, Sale contact= "& cstr(currentsale.contact.identity)
somessagebox "Boom"
 TCall = 0
 Validate()
End Sub
Sub OnCurrentSaleIdentityChanged()
somessagebox "Sale contact Identity Changed: "& cstr(currentsale.contact.identity)
End Sub
'*--------------------------------------------------------------------------------------------------------
Sub OnCurrentSaleCreated()
 sAmount = AddemUp
 currentSale.udef.ByProgId("SuperOffice:18").value = sAmount
 currentSale.Udef.save()
End Sub

Sub OnViewShown( hWnd, fullPath )
    If StrComp( fullPath, "MainWindow.SalePanel", vbTextCompare ) = 0 Then
 Validate()
    End If
End Sub
Sub OnEditSaleClicked()
'*somessagebox "Edit: "& cstr(currentsale.contact.identity)
 TCall = 0
 Validate()
End Sub
Sub OnCurrentSaleFieldChanged(FieldName)
'*somessagebox "changed: "+FieldName
If currentsale.udef.ByProgId("Superoffice:13").Value <> 1 then
 If InArray(FieldName,SumArray) <> 0 then
 sAmount =AddemUp
 currentSale.Udef.ByProgId("superOffice:33").value = sAmount
 currentSale.Udef.save()
 End if
End If
If InArray(FieldName,CheckFldArray) Then
'*SoMessageBox "Validate now: Checkfield"
 Validate()
End If
If InArray(FieldName,FordelArray) or InArray(FieldName,MonthArray) Then
'*SOMessageBox Fieldname
 If CurrentSale.Udef.ByProgId("Superoffice:36").Value = 1 then
  ResetFordelingsTal()
  Validate()
 End If
 If CurrentSale.Udef.ByProgId("Superoffice:36").Value = 0 then
 Validate()
 End If
End If
End Sub
Sub Validate()
ValResult = 0
If TCall = 0 then
TCall = TCall+1
CurrentSale.ValidationMessage = ""
'*SoMessageBox "Validate: " & ValResult
If CurrentSale.Udef.ByProgId("Superoffice:50").Value = 1 then
 If CurrentSale.Udef.ByProgId("Superoffice:36").Value = 0 then
   CheckFordeling()
 End If
End If
'*SoMessageBox "Validate Xstop"
'*SoMessageBox "Currentcontact: " &cstr(currentsale.contact.identity)
'*somessagebox "Stop value: "&currentSale.contact.Xstop
If currentSale.contact.Xstop = True or currentSale.contact.Xstop = "True" Then
 ValResult = ValResult+1
End if
'*SoMessageBox "Validate: " & ValResult
'*SoMessageBox "Validate Relation"
If checkRelationsStop(currentSale.Contact) <> 0 Then
 ValResult = ValResult+2
End If
'*SoMessageBox "Validate: " & ValResult
'*SOMessageBox "Validate Category"
If CurrentSale.Contact.Category.Id = 2 Then
 ValResult = ValResult +4
End If
'*SoMessageBox "Validate: " & ValResult
If CurrentSale.SaleType.Id = Aarsaftale Then
'*SoMessageBox "Check for Årsaftale " & cStr(ProjectLink(CurrentSale))
 If ProjectLink(CurrentSale) = 0 Then
  ValResult = ValResult +8
 End If
End If
'*SoMessageBox "Validateresult: " & cStr(ValResult)
Select Case ValResult
Case 1,101,201,1001,1101,1201
CurrentSale.ValidationMessage = CurrentSale.ValidationMessage + "Der er stop på den valgt kontakt. Salg må ikke registreres" + vbCrlf
CurrentSale.AutoSaveOnChangeIdentity = False
Case 2,102,202,1002,1102,1202
CurrentSale.ValidationMessage = CurrentSale.ValidationMessage + "Den valgt kontakt har en anden betaler med kategori emne eller hvorpå der er stop. Salg må ikke registreres" + vbCrlf
CurrentSale.AutoSaveOnChangeIdentity = False
Case 3,103,203,1003,1103,1203
CurrentSale.ValidationMessage = CurrentSale.ValidationMessage + "Der er stop på den valgt kontakt og dens anden betaler. Salg må ikke registreres" + vbCrlf
CurrentSale.AutoSaveOnChangeIdentity = False
Case 4,104,204,1004,1104,1204
CurrentSale.ValidationMessage = CurrentSale.ValidationMessage + "Salg må ikke registreres på Emner" + vbCrlf
CurrentSale.AutoSaveOnChangeIdentity = False
Case 5,105,205,1005,1105,1205
CurrentSale.ValidationMessage = CurrentSale.ValidationMessage + "Der er stop på den valgt kontakt. Salg må ikke registreres" + vbCrlf
CurrentSale.ValidationMessage = CurrentSale.ValidationMessage + "Salg må ikke registreres på Emner" + vbCrlf
CurrentSale.AutoSaveOnChangeIdentity = False
Case 6,106,206,1006,1106,1206
CurrentSale.ValidationMessage = CurrentSale.ValidationMessage + "Den valgt kontakt har en anden betaler med kategori emne eller hvorpå der er stop. Salg må ikke registreres"+ vbCrlf
CurrentSale.ValidationMessage = CurrentSale.ValidationMessage + "Salg må ikke registreres på Emner" + vbCrlf
CurrentSale.AutoSaveOnChangeIdentity = False
Case 7,107,207,1007,1107,1207
CurrentSale.ValidationMessage = CurrentSale.ValidationMessage + "Der er stop på den valgt kontakt og dens anden betaler. Salg må ikke registreres" + vbCrlf
CurrentSale.ValidationMessage = CurrentSale.ValidationMessage + "Salg må ikke registreres på Emner" + vbCrlf
CurrentSale.AutoSaveOnChangeIdentity = False
Case 8,108,208,1008,1108,1208
CurrentSale.ValidationMessage = CurrentSale.ValidationMessage + "Årsaftale projektlink mangler" + vbCrlf
CurrentSale.AutoSaveOnChangeIdentity = False
Case 9,109,209,1009,1109,1209
CurrentSale.ValidationMessage = CurrentSale.ValidationMessage + "Der er stop på den valgt kontakt. Salg må ikke registreres" + vbCrlf
CurrentSale.ValidationMessage = CurrentSale.ValidationMessage + "Årsaftale projektlink mangler" + vbCrlf
CurrentSale.AutoSaveOnChangeIdentity = False
Case 10,110,210,1010,1110,1210
CurrentSale.ValidationMessage = CurrentSale.ValidationMessage + "Den valgt kontakt har en anden betaler med kategori emne eller hvorpå der er stop. Salg må ikke registreres" + vbCrlf
CurrentSale.ValidationMessage = CurrentSale.ValidationMessage + "Årsaftale projektlink mangler" + vbCrlf
CurrentSale.AutoSaveOnChangeIdentity = False
Case 11,111,211,1011,1111,1211
CurrentSale.ValidationMessage = CurrentSale.ValidationMessage + "Der er stop på den valgt kontakt og dens anden betaler. Salg må ikke registreres" + vbCrlf
CurrentSale.ValidationMessage = CurrentSale.ValidationMessage + "Årsaftale projektlink mangler" + vbCrlf
CurrentSale.AutoSaveOnChangeIdentity = False
Case 12,112,21,1012,1112,1212
CurrentSale.ValidationMessage = CurrentSale.ValidationMessage + "Salg må ikke registreres på Emner" + vbCrlf
CurrentSale.ValidationMessage = CurrentSale.ValidationMessage + "Årsaftale projektlink mangler" + vbCrlf
CurrentSale.AutoSaveOnChangeIdentity = False
Case 13,113,213,1013,1113,1213
CurrentSale.ValidationMessage = CurrentSale.ValidationMessage + "Der er stop på den valgt kontakt. Salg må ikke registreres" + vbCrlf
CurrentSale.ValidationMessage = CurrentSale.ValidationMessage + "Salg må ikke registreres på Emner" + vbCrlf
CurrentSale.ValidationMessage = CurrentSale.ValidationMessage + "Årsaftale projektlink mangler" + vbCrlf
CurrentSale.AutoSaveOnChangeIdentity = False
Case 14,114,214,1014,1114,1214
CurrentSale.ValidationMessage = CurrentSale.ValidationMessage + "Den valgt kontakt har en anden betaler med kategori emne eller hvorpå der er stop. Salg må ikke registreres" + vbCrlf
CurrentSale.ValidationMessage = CurrentSale.ValidationMessage + "Salg må ikke registreres på Emner" + vbCrlf
CurrentSale.ValidationMessage = CurrentSale.ValidationMessage + "Årsaftale projektlink mangler" + vbCrlf
CurrentSale.AutoSaveOnChangeIdentity = False
Case 15,115,215,1015,1115,1215
CurrentSale.ValidationMessage = CurrentSale.ValidationMessage + "Der er stop på den valgt kontakt og dens anden betaler. Salg må ikke registreres" + vbCrlf
CurrentSale.ValidationMessage = CurrentSale.ValidationMessage + "Salg må ikke registreres på Emner" + vbCrlf
CurrentSale.ValidationMessage = CurrentSale.ValidationMessage + "Årsaftale projektlink mangler" + vbCrlf
CurrentSale.AutoSaveOnChangeIdentity = False
Case 100,200,1000,1100,1200
CurrentSale.AutoSaveOnChangeIdentity = False
Case Else
 CurrentSale.ValidationMessage = ""
 CurrentSale.AutoSaveOnChangeIdentity = True
End Select
End If
TCall = 0
End Sub
Sub Checkfordeling()
Fsum = 0
Msum = 0
If CurrentSale.Udef.ByProgId("SuperOffice:20").Value = 1 then
FSum = FSum + Currentsale.Udef.ByProgId("SuperOffice:38").Value
 If Currentsale.Udef.ByProgId("SuperOffice:38").Value = 0 then
  Msum = Msum+1
 End If
Else
 If Currentsale.Udef.ByProgId("SuperOffice:38").Value <> 0 then
  Currentsale.Udef.ByProgId("SuperOffice:38").Value = 0
 End If
End If
If CurrentSale.Udef.ByProgId("SuperOffice:21").Value = 1 then
FSum = FSum + Currentsale.Udef.ByProgId("SuperOffice:39").Value
 If Currentsale.Udef.ByProgId("SuperOffice:39").Value = 0 then
  Msum = Msum+1
 End If
Else
 If Currentsale.Udef.ByProgId("SuperOffice:39").Value <> 0 then
  Currentsale.Udef.ByProgId("SuperOffice:39").Value = 0
 End If
End If
If CurrentSale.Udef.ByProgId("SuperOffice:22").Value = 1 then
FSum = FSum + Currentsale.Udef.ByProgId("SuperOffice:40").Value
 If Currentsale.Udef.ByProgId("SuperOffice:40").Value = 0 then
  Msum = Msum+1
 End If
Else
 If Currentsale.Udef.ByProgId("SuperOffice:40").Value <> 0 then
  Currentsale.Udef.ByProgId("SuperOffice:40").Value = 0
 End If 
End If
If CurrentSale.Udef.ByProgId("SuperOffice:23").Value = 1 then
FSum = FSum + Currentsale.Udef.ByProgId("SuperOffice:41").Value
 If Currentsale.Udef.ByProgId("SuperOffice:41").Value = 0 then
  Msum = Msum+1
 End If
Else
 If Currentsale.Udef.ByProgId("SuperOffice:41").Value <> 0 then
  Currentsale.Udef.ByProgId("SuperOffice:41").Value = 0
 End If
End If
If CurrentSale.Udef.ByProgId("SuperOffice:24").Value = 1 then
FSum = FSum + Currentsale.Udef.ByProgId("SuperOffice:42").Value
 If Currentsale.Udef.ByProgId("SuperOffice:42").Value = 0 then
  Msum = Msum+1
 End If
Else
 If Currentsale.Udef.ByProgId("SuperOffice:42").Value <> 0 then
  Currentsale.Udef.ByProgId("SuperOffice:42").Value = 0
 End If
End If
If CurrentSale.Udef.ByProgId("SuperOffice:25").Value = 1 then
FSum = FSum + Currentsale.Udef.ByProgId("SuperOffice:43").Value
 If Currentsale.Udef.ByProgId("SuperOffice:43").Value = 0 then
  Msum = Msum+1
 End If
Else
 If Currentsale.Udef.ByProgId("SuperOffice:43").Value <> 0 then
  Currentsale.Udef.ByProgId("SuperOffice:43").Value = 0
 End If
End If
If CurrentSale.Udef.ByProgId("SuperOffice:26").Value = 1 then
FSum = FSum + Currentsale.Udef.ByProgId("SuperOffice:44").Value
 If Currentsale.Udef.ByProgId("SuperOffice:44").Value = 0 then
  Msum = Msum+1
 End If
Else
 If Currentsale.Udef.ByProgId("SuperOffice:44").Value <> 0 then
  Currentsale.Udef.ByProgId("SuperOffice:44").Value = 0
 End If
End If
If CurrentSale.Udef.ByProgId("SuperOffice:27").Value = 1 then
FSum = FSum + Currentsale.Udef.ByProgId("SuperOffice:45").Value
 If Currentsale.Udef.ByProgId("SuperOffice:45").Value = 0 then
  Msum = Msum+1
 End If
Else
 If Currentsale.Udef.ByProgId("SuperOffice:45").Value <> 0 then
  Currentsale.Udef.ByProgId("SuperOffice:45").Value = 0
 End If
End If
If CurrentSale.Udef.ByProgId("SuperOffice:28").Value = 1 then
FSum = FSum + Currentsale.Udef.ByProgId("SuperOffice:46").Value
 If Currentsale.Udef.ByProgId("SuperOffice:46").Value = 0 then
  Msum = Msum+1
 End If
Else
 If Currentsale.Udef.ByProgId("SuperOffice:46").Value <> 0 then
  Currentsale.Udef.ByProgId("SuperOffice:46").Value = 0
 End If
End If
If CurrentSale.Udef.ByProgId("SuperOffice:29").Value = 1 then
FSum = FSum + Currentsale.Udef.ByProgId("SuperOffice:47").Value
 If Currentsale.Udef.ByProgId("SuperOffice:47").Value = 0 then
  Msum = Msum+1
 End If
Else
 If Currentsale.Udef.ByProgId("SuperOffice:47").Value <> 0 then
  Currentsale.Udef.ByProgId("SuperOffice:47").Value = 0
 End If
End If
If CurrentSale.Udef.ByProgId("SuperOffice:30").Value = 1 then
FSum = FSum + Currentsale.Udef.ByProgId("SuperOffice:48").Value
 If Currentsale.Udef.ByProgId("SuperOffice:48").Value = 0 then
  Msum = Msum+1
 End If
Else
 If Currentsale.Udef.ByProgId("SuperOffice:48").Value <> 0 then
  Currentsale.Udef.ByProgId("SuperOffice:48").Value = 0
 End If
End If
If CurrentSale.Udef.ByProgId("SuperOffice:31").Value = 1 then
FSum = FSum + Currentsale.Udef.ByProgId("SuperOffice:49").Value
 If Currentsale.Udef.ByProgId("SuperOffice:49").Value = 0 then
  Msum = Msum+1
 End If
Else
 If Currentsale.Udef.ByProgId("SuperOffice:49").Value <> 0 then
  Currentsale.Udef.ByProgId("SuperOffice:49").Value = 0
 End If
End If
'*SOMessageBox "Fsum:" & cstr(Fsum)
Select Case  FSum
 Case 0
  If left(cstr(ValResult),2) <> 12 then
  ValResult = ValResult+200
  If CurrentSale.Udef.ByProgId("Superoffice:36").Value = 0 then
  Currentsale.ValidationMessage = CurrentSale.ValidationMessage + "Vælg måned(er) og Angiv Fordelings%" & vbCrLf
  End If
  End If
 Case 100
  Valresult = 0
 Case Else
  ValResult = ValResult +100
  Currentsale.ValidationMessage = CurrentSale.ValidationMessage + "Summen af Fordelings% <> 100" & vbCrLf
 End Select
'*SOMessageBox "Msum:" & cstr(Msum)
Select Case Msum
 Case 0
  ValResult = ValResult+0
 Case Else
  If left(cstr(ValResult),2) <> 12 then
  Valresult = Valresult+1000
  Currentsale.ValidationMessage = CurrentSale.ValidationMessage + "Der er valgt måneder uden angivelse af Fordelings%" & vbCrLf
  end If
 End Select
'*SOMessageBox "Fordeling val: " & cStr(FSum) & vbCrlf & cStr(ValResult)
End Sub
Sub ResetFordelingsTal()
Currentsale.Udef.ByProgId("SuperOffice:38").Value = 0
Currentsale.Udef.ByProgId("SuperOffice:39").Value = 0
Currentsale.Udef.ByProgId("SuperOffice:40").Value = 0
Currentsale.Udef.ByProgId("SuperOffice:41").Value = 0
Currentsale.Udef.ByProgId("SuperOffice:42").Value = 0
Currentsale.Udef.ByProgId("SuperOffice:43").Value = 0
Currentsale.Udef.ByProgId("SuperOffice:44").Value = 0
Currentsale.Udef.ByProgId("SuperOffice:45").Value = 0
Currentsale.Udef.ByProgId("SuperOffice:46").Value = 0
Currentsale.Udef.ByProgId("SuperOffice:47").Value = 0
Currentsale.Udef.ByProgId("SuperOffice:48").Value = 0
Currentsale.Udef.ByProgId("SuperOffice:49").Value = 0
End Sub
Function checkRelationsStop(x)
Result = 0
set sorelations = x.getrelations
    set relation = sorelations.getfirst
    while not sorelations.eof
        if relation.sourcetable = 5 and relation.type  = AndenBetalerRel then
             cont = relation.targetrecord.Identity
   Set CheckCont = database.GetContact(cont)
   '* SoMessageBox x.name
    '*SoMessageBox CheckCont.name & " " & CheckCont.Category.Id & " " & CheckCont.Xstop
  If x.identity <> cont then
'*SoMessageBox "Kontrollerer status på Anden Betaler: " & CheckCont.name & " " & CheckCont.Category.Id & " " & CheckCont.Xstop
   If Checkcont.xstop = "True" or Checkcont.xstop = "Sand" or CheckCont.Category.Id = 2 then
    Result = 1
             End if
  End If
        end if
        set relation = sorelations.getnext
    wend
 '*SoMessageBox "CheckRelationStop result: " & Result
checkRelationsStop = Result
End Function
Function AddemUp()
int1 = currentsale.udef.ByProgId("Superoffice:2").Value
int2 = currentsale.udef.ByProgId("Superoffice:3").Value
int3 = currentsale.udef.ByProgId("Superoffice:4").Value
int4 = currentsale.udef.ByProgId("Superoffice:5").Value
int5 = currentsale.udef.ByProgId("Superoffice:6").Value
int6 = currentsale.udef.ByProgId("Superoffice:7").Value
int7 = currentsale.udef.ByProgId("Superoffice:8").Value
int8 = currentsale.udef.ByProgId("Superoffice:9").Value
int9 = currentsale.udef.ByProgId("Superoffice:10").Value
int10 = currentsale.udef.ByProgId("Superoffice:11").Value
int11 = currentsale.udef.ByProgId("Superoffice:12").Value
int12 = currentsale.udef.ByProgId("Superoffice:32").Value
sTotal = int1+int2+int3+int4+int5+int6+int7+int8+int9+int10+int11+int12
AddemUp = sTotal
End Function
Function InArray(y,arr)
i=0
result = 0
Do While i <= UBOUND(arr)
'*SOMessageBox y & " : " & arr(i)
 If y = arr(i) then
  Result = 1
  Exit Do
'*180
 Else
  Result = 0
  i = i+1
 End If
Loop
'*SoMessageBox Result
InArray = Result
End function
Function ProjectLink(x)
'*SOMessageBox "Link check start"
Result = 0
set link = x.ActivityLinks
'*SOMessageBox "Count: " &  link.projects.count
For Each item In link.Projects
If item.type.Id = Database.GetListItemByName (enTableProjType, "Årsaftale").Id then
Result = Result+1
End If
Next
ProjectLink = Result
End Function
 
 
 
Af: Jason Tiler Broad 15. maj 2018

RE: Order of events in 8.2 sr-04

And here's the order of events in 7.5

 


     1: 11:13:26:648  OnSalePanelShown (1) 
     2: 11:13:27:81  OnCurrentSaleIdentityChanged (1) 
     3: 11:13:27:141  OnCurrentPricelistIdentityChanged (1) 
     4: 11:13:27:143  OnCurrentProductIdentityChanged (1) 
     5: 11:13:27:253  OnSaleFieldsChanged (1)  [VT_BSTR] SetContactId, [VT_UI4]0, [VT_BSTR] contact_id, [VT_INT]3331
     6: 11:13:27:256  OnCurrentSaleFieldChanged (1)  [VT_BSTR] sale.contact_id
       (6) - 11:13:27:257  JFM_CheckSaleXstop_V2.vbs
     7: 11:13:27:312  OnSaleFieldsChanged (1)  [VT_BSTR] SetAssociateId, [VT_UI4]0, [VT_BSTR] associate_id,group_idx, [VT_INT]3329, [VT_INT]3330
     8: 11:13:27:314  OnCurrentSaleFieldChanged (1)  [VT_BSTR] sale.associate_id
       (8) - 11:13:27:315  JFM_CheckSaleXstop_V2.vbs
     9: 11:13:27:318  OnCurrentSaleFieldChanged (1)  [VT_BSTR] sale.group_idx
       (9) - 11:13:27:320  JFM_CheckSaleXstop_V2.vbs
    10: 11:13:27:338  OnSaleFieldsChanged (1)  [VT_BSTR] SetSaleTypeId, [VT_UI4]0, [VT_BSTR] saleType_id,saledate,saleTypeCat_id, [VT_INT]3361, [VT_INT]3334, [VT_INT]3368
    11: 11:13:27:343  OnCurrentSaleFieldChanged (1)  [VT_BSTR] sale.saleType_id
       (11) - 11:13:27:345  JFM_CheckSaleXstop_V2.vbs
    12: 11:13:27:371  OnCurrentSaleFieldChanged (1)  [VT_BSTR] sale.saledate
       (12) - 11:13:27:374  JFM_CheckSaleXstop_V2.vbs
    13: 11:13:27:377  OnCurrentSaleFieldChanged (1)  [VT_BSTR] sale.saleTypeCat_id
       (13) - 11:13:27:379  JFM_CheckSaleXstop_V2.vbs
    14: 11:13:27:382  OnSaleFieldsChanged (1)  [VT_BSTR] SetNextDueDate, [VT_UI4]0, [VT_BSTR] nextDueDate,nddAppointment_id, [VT_INT]3365, [VT_INT]3366
    15: 11:13:27:386  OnCurrentSaleFieldChanged (1)  [VT_BSTR] sale.nextDueDate
       (15) - 11:13:27:388  JFM_CheckSaleXstop_V2.vbs
    16: 11:13:27:390  OnCurrentSaleFieldChanged (1)  [VT_BSTR] sale.nddAppointment_id
       (16) - 11:13:27:393  JFM_CheckSaleXstop_V2.vbs
    17: 11:13:27:416  OnSaleFieldsChanged (1)  [VT_BSTR] SetProbabilityId, [VT_UI4]0, [VT_BSTR] probability_idx,probability, [VT_INT]3336, [VT_INT]3350
    18: 11:13:27:420  OnCurrentSaleFieldChanged (1)  [VT_BSTR] sale.probability_idx
       (18) - 11:13:27:422  JFM_CheckSaleXstop_V2.vbs
    19: 11:13:27:425  OnCurrentSaleFieldChanged (1)  [VT_BSTR] sale.probability
       (19) - 11:13:27:427  JFM_CheckSaleXstop_V2.vbs
    20: 11:13:27:437  OnSaleFieldsChanged (1)  [VT_BSTR] SetNextDueDate, [VT_UI4]0, [VT_BSTR] nextDueDate,nddAppointment_id, [VT_INT]3365, [VT_INT]3366
    21: 11:13:27:440  OnCurrentSaleFieldChanged (1)  [VT_BSTR] sale.nextDueDate
       (21) - 11:13:27:442  JFM_CheckSaleXstop_V2.vbs
    22: 11:13:27:445  OnCurrentSaleFieldChanged (1)  [VT_BSTR] sale.nddAppointment_id
       (22) - 11:13:27:447  JFM_CheckSaleXstop_V2.vbs
    23: 11:13:27:655  OnEditSaleClicked (1) 
       (23) - 11:13:27:657  JFM_CheckSaleXstop_V2.vbs

Af: Jason Tiler Broad 15. maj 2018

RE: Order of events in 8.2 sr-04

Hi Jason,

Sub OnPersonFieldsChanged( action, identity, fieldNames, calldepth ) 
   .........
End Sub 

 

I have registered:
           tfs 58891: Win - Script Events issue in Sale

I will look into this in 8.3 for the upcoming personize release (person panel only, no more dialog).
Regards,
Conrad

 

Af: Conrad Weyns 16. maj 2018

RE: Order of events in 8.2 sr-04

Thanks Conrad,

On the second call to OnPersonFieldsChanged that comes after clicking new sale the sale.contact.identity is set so I can get it to react properly again.

regards,

Jason

Af: Jason Tiler Broad 17. maj 2018

RE: Order of events in 8.2 sr-04

Hi Jason,
I am glad you seem to have a work-around.
Overall, I am not to happy about this. The event system ties our hands and feet behind our back.
Sometimes we make some changes advantageous for our GUI and break or risk breaking some scripting client.

Very hard to control and in this respect Sale is the hardest (very noisy) closely followed by Document and Appointment.
Contact, Person, Project and Selection are much simpler.

/conrad

Af: Conrad Weyns 18. maj 2018

RE: Order of events in 8.2 sr-04

I fixed this in the upcoming 8.3.
I have made sure that OnEditSaleClicked will be called after all the rest of the model noise is done.
You should then be able to get all set identities.

There are also new defaults messages in 8.3, e.g. OnCurrentSaleDefaults called after we have set all defaults (silently!) and return control to the GUI. (This may or may not be interesting..)

/conrad

 

This script works for me now:

--------------------------------------------------------

Sub OnEditSaleClicked()
    Set sale = CurrentSale
    msg = ""
    If sale.Identity = 0 Then
        msg = "Create sale:" & vbCrLf
    Else
        msg = "Edit sale:" & vbCrLf
    End If

    msg = msg & "Contact: " & sale.Contact.Name & vbCrLf
    msg = msg & "Person: " & sale.Person.FullName & vbCrLf
    ms­g = msg & "Project: " & sale.Project.Name & vbCrLf
    SoMessageBox msg
End Sub

Af: Conrad Weyns 19. maj 2018