Wednesday, March 26, 2014

Changing Default Currency in a Data Entry Screen

Hi Everyone,

One of our customer asked to change the USD currency, system uses by default, when opening an empty data entry screen. Say if our base currency is USD, system will use it as default, but in that particular screen, say Journal Transactions entry, they wanted it to be SGD. Just because 90% of all the entries in that screen are SGD. Seemed simple... but...



We faced a real issue customizing it, Currency control is a specific one... And currency rate needs to get auto updated...

Finally, with Ruslan's help we've found a workaround.

All is needed - to add below code to a constructor of the Journal Entry screen:

  #region Event Handlers
protected override void Batch_CuryID_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e)
{
  e.NewValue = "SGD";
  e.Cancel = true;
}


protected override void CurrencyInfo_CuryID_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e)
{
                e.NewValue = "SGD";
                e.Cancel = true;  
}

protected override void CurrencyInfo_RowInserting(PXCache sender, PXRowInsertingEventArgs e)
{
    base.CurrencyInfo_RowInserting(sender, e);
    sender.RaiseFieldUpdated<CurrencyInfo.curyID>(e.Row, null);
}


All the best,

Sergey.

No comments:

Post a Comment