Thursday, September 29, 2022

#931 - Message Driven Processes with OPA - OAuth Setup

 








A very simple process, just to illustrate how easy this is with OPA.













I Activate and then click on View API







So now I have the endpoint - I need to authenticate via OAuth; so before I can test this I need to register my Oracle Cloud Infrastructure Process Automation instance as a confidential application in Oracle Identity Cloud Service.


Here is the configuration of my Confidential Application -







That's it - but please note the redirect uri has the same format as that for OIC Gen2. 

https://Your-OPA.process.oci.oraclecloud.com/icsapis/agent/oauth/callback

Also note the 2 scopes - one for Process and one for Decisions.

I save the client id and secret and then base64 encode them.



And yes, I still use Windows, or, as we say, in Gaeilge - fuinneoga.



Next step - get an Authorization Code

https://yourIDCSUrl/oauth2/v1/authorize?client_id=yourClientId&response_type=code&scope=https://yourOPAUrl.process.oci.oraclecloud.com/process offline_access&redirect_uri=https://yourOPAURL.process.oci.oraclecloud.com/icsapis/agent/oauth/callback

So, I've now got encoded client id and secret as well as the authorization code - time to get the auth token - 

curl -i -H "Authorization: Basic yourBase64EncodedClientIdSecret" --request POST "https://yourIDCSUrl/oauth2/v1/token" -H "Content-Type:application/x-www-form-urlencoded" -d "grant_type=authorization_code&code=yourAuthorizationCode"

I take the code and now set up the invoke of my Process in Postman - 


Here is the OAuth Configuration - 



Note: Scope is set to https://yourOPA.process.oci.oraclecloud.com/process

I enter the process payload - my Order - 


and test - I see the following error message in Postman -



 Quite correct, I have not assigned any users to my Process role. I return to Process Workspace and do this - 










Now back to Postman - 




That's more like it!

Invoking OPA REST APIs is simple, once you have done the initial setup.

Final step - I validate in OPA Workspace - 



























Wednesday, September 21, 2022

#930 - OIC -> Create Customer in Fusion ERP



I have a simple use case here - customer details are entered in SFDC, OIC is invoked to create the relevant customer in Fusion ERP. In Fusion Sales we have the Accounts object, Financials uses Hub Persons / Organizations to express business relationships.

The latter can be created in Financials - I navigated via -


 

The REST APIs needed to create both types of customers are described here 










Let's look at Hub Organizations






Here is an example payload - 

{
"PartyNumber": "123456",
"SourceSystemReference": [
{
"SourceSystem": "SFDC",
"SourceSystemReferenceValue": "SFDC1234"
}
],
"OrganizationName": "Commiskey Loudspeakers Inc.",
"PartyUsageCode": "EXTERNAL_LEGAL_ENTITY",
"RawPhoneNumber": "9199199199",
"EmailAddress": "niall@commiskeyLoudspeakers.com",
"URL": "www.commiskeyLoudspeakers.com",
"Address": [
{
"AddressType": "BILL_TO",
"Address1": "1916 11th Ave",
"City": "San Francisco",
"Country": "US",
"County": "San Francisco",
"PostalCode": "94116",
"PostalPlus4Code": "",
"State": "CA"
}
],
"CorpCurrencyCode": "USD",
"CurcyConvRateType": "Corporate",
"CurrencyCode": "USD",
"DUNSNumber": "20091962"
}

Note the link to the SFDC source system. This source system code will have to exist in Fusion.











I validate in Financials -


Now back to the Postman response - 


Party Id has been generated by Fusion, the other values are self-explanatory.

Now to the Source System part of the response -


 


Finally, the Address details - 



Looks good, however, the customer isn't active from an accounting perspective until the following details have been entered - Accounts and Sites



 Here we will use the SOAP based api - 

foundationParties/CustomerAccountService

The PartyId and AddressId returned by the REST invoke will be needed here.

But first, let's create an integration in OIC for the initial customer creation. ERP adapter configuration is as follows - 




 














I then select the create option.

I used my Postman request payload as the Trigger request, so mapping is very easy - 








I activate and test -



Tuesday, September 13, 2022

#929 OIC - HCM Register for Training - Create Absence Use case







This is a typical HCM extension use case for OIC. Allow employees to register for training, the registration resulting in the creation of the relevant absence record in Fusion HCM. My usual caveat applies here - I am not an HCM expert, but this post may be useful for other integration specialists tasked with doing such. As usual I am leveraging Postman at the outset - 

The HCM REST API doc is a good place to start - 







The following seems to be the basic payload required to create an absence record -

{"personNumber"7,
"absenceType""Training",
"employer":"US1 Legal Entity",
"startDate":"2023-09-27",
"endDate""2023-09-28",
"absenceStatusCd":"SUBMITTED",
"startDateDuration"8,
"endDateDuration"8}

personNumber identifies the employee

absenceType = "Training" - makes sense for this use case.

employer - so where do I get this info? Let's look up our employee - Alan Cook - in HCM -








There we find the legal employer.

absenceStatus can be set to SAVED or SUBMITTED

personNumber identifies the employee - I retrieved this by executing the following REST request -

/hcmRestApi/resources/11.13.18.05/emps?q=FirstName=Alan;LastName=Cook&fields=PersonId,PersonNumber

startDateDuration/endDateDuration refers to the number of hours which will be assigned to Training. In my case, full days - i.e. 8 hours.

The response - 


 






Now to the UI, here I use Visual Builder - 









Now to Fusion HCM - I begin by creating a Sandbox - 


Ensure Page Integration is active for this sandbox - 














I then navigate to Page Integration -










Next step is to position this new page in the Fusion HCM structure - 






Per default, the new page has been located here - 


Let's move it to the Me group -








One has to activate anonymous access to the Visual Builder app to get this working - in real-life one would do this via SSO - a subject for a future blog post.

Now to the OIC integration that creates the absence record in HCM.

I leverage the OIC HCM Adapter here, which essentially invokes the REST service I already tested in Postman.

The payload is the same as the Postman request - 














The HCM Invoke is configured as follows - 














Mapping is simply to target fields of the same name.

personAbsenceEntryId is the return value we are interested in. This id can be used to retrieve the absence record from HCM - 





 

The final piece we need to add is the invoke of the OIC endpoint from Visual Builder - 

I start by creating a connection definition.


 







Now to invoking this from the Create page actionChain -



Let's try out the whole flow - 








We can validate in HCM -