Page 1 of 1

Drs New Custom field issue

PostPosted: Wed Feb 03, 2016 2:59 pm
by 2can2
Hi, using V149 I have managed to add code to set a Date Custom field on Debtors to SystemDate if another Custom Tick box is Ticked. Works great for Custom Field changes. However I can't seem to add the code that would allow a NEW Debtor to be created as the CustomDate field is not being set so it errors immediately on new with 'Input String was not in the correct format. Module 'ParsDouble'.
I know this pretty basic but I can't seem to addHandler for ReadEnd or SaveStart routines so I can set the CustomDate field to = Systemdate. Code Below:

Code: Select all
'  **** Define the handler actions needed - (2nd + 4th lines) - DH 280116
Public Sub Setup(ByVal JiwaBusinessLogic As JiwaApplication.IJiwaBusinessLogic, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaBusinessLogicPlugin.Setup
   _DebtorObject = DirectCast(JiwaBusinessLogic, JiwaDebtors.Debtor)
'   DCU = _DebtorObject.Debtor   ** Can't get this to work??
   AddHandler _DebtorObject.CustomFieldValues.Changed, AddressOf CustomFieldValues_Changed
'   AddHandler _DebtorObject.CustomFieldValues.ReadEnd, AddressOf CustomFieldValues_ReadEnd  ***??
'   AddHandler _DebtorObject.SaveStart, AddressOf _DebtorObject_SaveStart                                   **??
   
End Sub

'  *** If QualityCheck Ticked then QCDate = Login Date!! NB Custom Date fields handle as normal! DH 280116
Private Sub CustomFieldValues_Changed(item As JiwaApplication.CustomFields.CustomFieldValue, e As System.ComponentModel.PropertyChangedEventArgs)
   If item.CustomField.PluginCustomField.Name = "QualityCheck" Then
'         MsgBox (item.Contents)
      If item.Contents = True Then
         _DebtorObject.CustomFieldValues.ItemFromSettingName(DBCustomFieldName_QCDate).Contents = JiwaApplication.Manager.Instance.SysDateTime
      End If   
   End If
End Sub


I have no access to a developer at the moment hence the basic queries - apologies.

Re: Drs New Custom field issue

PostPosted: Sun Feb 07, 2016 1:15 pm
by Mike.Sheen
Code: Select all
_DebtorObject.CustomFieldValues.ItemFromSettingName(DBCustomFieldName_QCDate).Contents = JiwaApplication.Manager.Instance.SysDateTime


JiwaApplication.Manager.Instance.SysDateTime is a date, and you can't just put it into a string - you need to explicitly convert it to a string.

e.g.:
Code: Select all
_DebtorObject.CustomFieldValues.ItemFromSettingName(DBCustomFieldName_QCDate).Contents = JiwaApplication.Manager.Instance.SysDateTime.ToString()


Note that you can specify the formatting, if desired - eg:

Code: Select all
_DebtorObject.CustomFieldValues.ItemFromSettingName(DBCustomFieldName_QCDate).Contents = JiwaApplication.Manager.Instance.SysDateTime.ToString("yyyy-MM-dd")

Re: Drs New Custom field issue  Topic is solved

PostPosted: Tue Feb 09, 2016 6:03 pm
by 2can2
Hi Mike, It still gives exactly the same error on NEW using .TOString()

It worked fine before adding the TOString() when editing an existing Debtor but still the same issue on a NEW.
Do I need an extra handler for new? Cheers