Drs New Custom field issue  Topic is solved

Discussions relating to Jiwa 7 plugin development, and the Jiwa 7 API.

Drs New Custom field issue

Postby 2can2 » Wed Feb 03, 2016 2:59 pm

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.
2can2
Frequent Contributor
Frequent Contributor
 
Posts: 171
Joined: Tue Feb 26, 2008 10:24 am
Topics Solved: 25

Re: Drs New Custom field issue

Postby Mike.Sheen » Sun Feb 07, 2016 1:15 pm

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")
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: Drs New Custom field issue  Topic is solved

Postby 2can2 » Tue Feb 09, 2016 6:03 pm

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
2can2
Frequent Contributor
Frequent Contributor
 
Posts: 171
Joined: Tue Feb 26, 2008 10:24 am
Topics Solved: 25


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 6 guests