Henning
5 months agoValued Contributor II
Rule to write to Cell Details?
Is there a way to save entries in Cell Details using a business rule?
Yes, here is a very simple rule to do just that ('simple', i.e. you will need to adjust this to your use case and make this nicer and more dynamic):
'General Declarations Dim listTargetDC As New List(Of DataCellEx) Dim listLineItems As New List(Of lineItem) 'Define the individual data cell target that is to be saved in the cube data model Dim dcpkReference = New DataCellPk(api.Pov.GetDataCellPk) 'here, the POV is determined by the DM step's POV settings Dim dcpkTarget As DataCellPk = dcpkReference Dim dCellAmount As Decimal = 321 'Storage Type --> "Input" Dim dcTarget As New DataCell(dcpkTarget, dCellAmount, DataCellStatus.CreateDataCellStatus(False, False)) 'Define the data cell's V#Annotation (Note: This only works on V#Annotation) Dim sAnnotation As String = String.Empty 'dcpkTarget.ViewId = BRApi.Finance.View.GetIdFromName(si, "Annotation") 'to set Annotation, if needed 'sAnnotation = "MyDataCellAnnotationString" 'Define line item detail to be saved as Cell Detail Dim dLineItemDetailAmount As Decimal = 9 ' --> This will override dCellAmount; Storage Type --> "DataCellDetailPeriodic" Dim sClassification As String = String.Empty ' --> "Not Used" Dim sLineItemDescription As String = "MyLineItemDescription" Dim mylineItem As New lineItem(lineItemType.Default, dLineItemDetailAmount, 1, sClassification, sLineItemDescription) 'also possible: lineItemType.ImportOffset 'Add line item to line item List listLineItems.Add(mylineItem) Dim listLineItem As New lineItemlist("lastEditedUserNameString", Date.Now, listLineItems) 'Create complete Data Cell Detail Dim cellViewType As New DataCellDetailViewType() Dim dcDetailTarget As New DataCellDetail(cellViewType, listLineItem) 'Define DataCellEx Dim dcExTarget As New DataCellEx(dcTarget, sAnnotation, currencyId.USD, accountTypeId.Revenue, dcDetailTarget) 'Add DataCellEx to list of DataCellExs listTargetDC.Add(dcExTarget) 'Set all data cells using DataCellExs details BRApi.Finance.Data.SetDataCells(si, listTargetDC)
I had a request which required me to test this today and I thought I'd share this in case someone benefits from it someday.
Please note that using SetDataCells actually saves the data as it has been entered via a form. Storage Type will not be "Calculated". One can use the above to set data, annotation and cell detail for a given POV. Keep in mind that when cell details are used, data (dCellAmount in the code above) will be overridden.