connector business rule

jeffvdt
New Contributor II

Hi All,

 

I think i have a very simple requirement but i cant seem to get it to work. I just want the API to make use of the entity which the user is currently using in the workflow. The code i now have is as following

                   Dim sURL As String = "xxx"
                    Dim pkWFunitPk As WorkflowUnitPk = BRApi.Workflow.General.GetWorkflowUnitPk(si)
Dim sYear As String = TimeDimHelper.GetYearFromId(pkWFunitPk.TimeKey).ToString
                        Dim sPeriod As String = TimeDimHelper.GetSubComponentsFromId(pkWFunitPk.TimeKey).Month.ToString
                        Dim sAPIKey As String = "xxx"
                        Dim sYearPeriodParam As String = String.Format("?yearPeriod={0}{1}", sYear, sPeriod)
                        Dim sEntities As String = "&company=244"
                        'Dim sEntityParam As String = String.Format("&company=[{0}]", sEntities)
                        Dim sJson As String = String.Empty
 
                        '----------------------------------------------------------------------------------------------------
 
                        'Execute HTTP Request
                        Using client As New HttpClient
                            client.DefaultRequestHeaders.Add("Client_Secret", sAPIKey)
 
                            'Send the GET request
                            Dim response As HttpResponseMessage = client.GetAsync(String.Format("{0}{1}{2}", sURL, sYearPeriodParam, sEntities)).Result
                            response.EnsureSuccessStatusCode()
1 ACCEPTED SOLUTION

Hi,

If all this is in a Connector Rule then you can use the api object to get the information for the current workflow so you don't  need to use the BRApi to retrieve the WorkflowInfo object i.e.  api.WorkflowProfile.ProfileKey

So you would only need this code:

Dim sEntityFilter As String = BRApi.Workflow.Metadata.GetProfileEntitiesAsMemberFilter(si, api.WorkflowProfile.ProfileKey)

View solution in original post

6 REPLIES 6

SH_INT
Contributor

Hi,

Just to clarify are you trying to get the Entities assigned to the current workflow and are the Entity names the same as in the source system?  

 

jeffvdt
New Contributor II

Yes, i just want to use the entities assigned to the current workflow. Entity name is the same as in ERP so thats easy i think 🙂 Thanks for your help!!!!

The following will return you a comma delimited string like this:

E#[381],E#[145],E#[492],E#[573]

Dim wfProfileInfo As WorkflowProfileInfo = BRApi.Workflow.Metadata.GetProfile(si, "NameOfYourWFProfile")
Dim sEntityFilter As String = BRApi.Workflow.Metadata.GetProfileEntitiesAsMemberFilter(si, wfProfileInfo.ProfileKey)

 

Therefore you will probably want to format the string to get rid of the Dimension flag e.g.

sEntityFilter.Replace("E#",String.Empty)

jeffvdt
New Contributor II

Thanks! Almost there, how do i make the NameofYourWPProfile dynamic. We have around 100 WFProfiles, is it possible to fetch automatically when werun a package from the workflow. Otherwise i cant make it dynamic and have to specify the Names still..

Hi,

If all this is in a Connector Rule then you can use the api object to get the information for the current workflow so you don't  need to use the BRApi to retrieve the WorkflowInfo object i.e.  api.WorkflowProfile.ProfileKey

So you would only need this code:

Dim sEntityFilter As String = BRApi.Workflow.Metadata.GetProfileEntitiesAsMemberFilter(si, api.WorkflowProfile.ProfileKey)

jeffvdt
New Contributor II

Thanks! Worked!!!