Forum Discussion

JérémyRenard's avatar
JérémyRenard
New Contributor II
1 day ago

Managing Group Company Exits in the User Workflow View

Hello everyone,

We have several companies that have been sold or dissolved.

To simplify users’ work, we would like to stop displaying workflows for these entities for periods when they no longer exist within our group.

I’m not sure if this is the recommended approach, so please feel free to share your best practices with me.

For my part, I have several ideas:

  • Revoke access to the workflowProfile of the relevant entities via the access permissions of the users responsible for importing the data.
  • Use a Business Rule to retrieve the name of the entity linked to the user’s workflow and, using its Entity ID, retrieve the date the company left the group, which is stored in Text6.

This way, I could either display no periods (meaning there would be no workflow), display all 12 periods, or display only the X months of the year the user was in the group.

I can retrieve the ID of the entity assigned to the workflow, but I can’t retrieve the data in Text6.

I get the error “Object reference not set to an instance of an object.”

If args.MemberListArgs.MemberListName.XFEqualsIgnoreCase("IsFormValidForEntity") Then
	'-- Usage: T#Root.CustomMemberList(BRName=JR_MemberList, MemberListName=IsFormValidForEntity, CVName=[RLS010 Local - Compte de résultat])
	'T#|WFTime|
	
	Dim WfGUID As guid = si.WorkflowClusterPk.ProfileKey 'obtient la clé de profil du workflow actuel de l'utilisateur
	
	Dim EntityList As List(Of WorkflowProfileEntityInfo) = BRApi.Workflow.Metadata.GetProfileEntities(si, WfGUID)
	Dim entityId As Integer
	
	For Each eInfo As WorkflowProfileEntityInfo In EntityList
		api.LogMessage("Workflow Entity:" & eInfo.EntityName)
		entityId = BRApi.Finance.Members.GetMemberId(si, DimType.Entity.Id, eInfo.EntityName)
		api.LogMessage("entityId :" & entityId)							
	Next
	
	Dim entityText6 As String = api.entity.Text(entityId,6).ToString	'<-- Error Object reference not set to an instance of an object.
	api.LogMessage("entityText6 :" & entityText6)

Do you have any advice on the best way to handle an entity’s departure from the group, while retaining or not retaining the ability to access its previous workflows?

Sincerely,

4 Replies

  • rhankey's avatar
    rhankey
    Contributor III

    The syntax of your code looks fine to my eyeballs.

    However, the way you have written the code, you are attempting to retrieve Text6 for the last Entity in the list of assigned entities, assuming there were any assigned entities.  If there were no assigned entities, EntityId will remain unassigned, and is one way to cause the function to get Text6 to barf.  Are you positive the EntityId is valid when you go to retrieve Text6?

    The only way the api.Entity.Text(EntityId,6) should fail is if EntityId is unassigned, set to DimConstants.Unknown, or is otherwise invalid.

    • JérémyRenard's avatar
      JérémyRenard
      New Contributor II

      Hello rhankey,

      Thank you for your feedback. I can confirm that I do indeed have the ID of my entity, which has been retrieved.

      Each workflow profile is assigned to one and only one entity.

      Here is the log output:

       

      It seems to me that it's retrieving an empty field, even though I do have a date stored in the entity's text6 field.

       

  • MarcusH's avatar
    MarcusH
    Valued Contributor

    The GetMemberId procedure needs the DimTypeID not the DimType i.e. DimTypeId.Entity

    entityId = BRApi.Finance.Members.GetMemberId(si, DimTypeId.Entity, eInfo.EntityName)

     

    • rhankey's avatar
      rhankey
      Contributor III

      I don't see an issue with how the DimType Id was specified.  DimTypeId.Entity = DimType.Entity.Id