Community
Showing results for 
Search instead for 
Do you mean 
Reply

field calc code

New Member
Posts: 2
Country: United States

field calc code

[ Edited ]

Is there an updated sample (vb or C# is ok) for doing simple field calculation via a plugin? I'm not looking for anything fancy.  I just need the ability to drop in a .dll that will multiply two fields and place the result in another field. I've been using this old code from 7.0.4 I believe, and it works, but it doesn't seem to be efficient.  I put a messagebox in the CalcDataFields procedure and  each time it does a calculation it seems to run the procedure again, adding an additional iteration each time.  So, by the time you've advanced from record to record 50 times it actually runs the procedure 50+ times on a single contact change.  I don't think I'm doing anything different from what the sample code I used is doing, that should have this effect.

If more detailed code is needed I can provide it.  I tried to simplify it a bit to get to the point.

 

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

 Private Sub ACTAPP_ViewLoaded(ByVal Sender As Object, ByVal e As Act.UI.ViewEventArgs)
        AddHandler ACTAPP.CurrentContactChanged, AddressOf ChangedContactField
  End Sub

  Public Sub ChangedContactField(ByVal Sender As Object, ByVal e As System.EventArgs)
        AddHandler fChanged, AddressOf CalcDataFields RaiseEvent fChanged("TBL_CONTACT.FULLNAME")
  End Sub

Public Sub CalcDataFields(ByVal tField As String)
  'calculation takes place here
End Sub
------------------------------------------------------- 


Any help on why this is happening would would be appreciated.  Or even better would be if someone can point me to updated sample code that does
simple field manipulation when the current contact changes.


Thanks,
Will Phipps
Kirkwood Technologies Inc.

 

Message Edited by willphipps on 04-22-2010 08:26 AM
New Member
Posts: 2
Country: United States

Re: field calc code

Anybody???  Guys from Sage? 

 

Thanks,
Will Phipps
Kirkwood Technologies Inc.

Nickel Elite Contributor
Posts: 937
Country: USA

Re: field calc code

I had posted a sample custom control that uses OLEDB2 on Opportunities where I do a calculation of average opportunity size that you could look at.  Consider writing a custom control instead of a plugin - The control can take values from 2 other fields and add or concatenate them then populate the control value.  If you're loking to perisit that calculated value then make the control bind to a property then the change event of the record should save the value to the bound property (field).

 

I think in my example I just populate a label control so I don't do binding but all of the code to get current record context (using the currency manager in .Net) is there. 

Nickel Elite Contributor
Posts: 937
Country: USA

Re: field calc code

http://community.act.com/sage/board/message?board.id=ADN_Downloads&thread.id=226

 

Link to the custom control example I was referring to earlier.