Submit a ticket
Welcome
Login

Contract Create APEX action

The Contract Create Apex action is used to create Oneflow contracts in Salesforce using flows.

Input Fields

This action includes six input fields.

1. Define the Oneflow Contract name - Enter the name of the contract or select it from a flow variable.

2. Insert here your Oneflow Workspace Id - Enter the Oneflow Workspace ID select it from a flow variable.

3. Select one template Id available in your Oneflow workspace - Enter the Oneflow Template ID select it from a flow variable.

4. Select the Id of the record related to the Oneflow Contract - Enter the Record ID of the Salesforce record where you want to associate the contract select it from a flow variable. For example, if you want to link the contract to a specific Opportunity, enter that Opportunity ID here.

5. Attachments Inputs - new resource list of Apex-Defined OneflowAttachment class - An Apex-defined collection variable that contains OneflowAttachment objects. (You’ll need to create this by querying the required Salesforce Attachment records.)

6. Participant Inputs - new resource list of Apex-Defined PotentialParticipant class - An Apex-defined collection variable that contains PotentialParticipant objects.(You’ll need to create this by querying the required Salesforce records.)



Creating a New Resource List of the Apex-Defined PotentialParticipant Class

  1. First, you need to create the required Apex-defined variables to hold the data. In this case, create an Apex-defined variable for a single PotentialParticipant, and another Apex-defined collection variable to store a list of PotentialParticipants. To create these variables, go to the Toolbox section in the Flow Builder and click on New Resource.
    1. How to create Apex-defined variable for  PotentialParticipant
      1. Resource Name → Variable
      2. API name → API name for the resource (Ex: OneflowParticipant)
      3. Data Type → Select Apex-Defined
      4. Apex Class → Select OFapp__PotentialParticipant from the drop down
      5. Check the Available for input checkbox
    2. How to create an Apex-defined collection variable for PotentialParticipant
      1. Follow the same steps as when creating the Apex-defined variable for a single PotentialParticipant. This time, make sure to check the Allow multiple values (collection) checkbox to create a collection variable.
  2. Next, use the Get Records flow element to query the records you want to assign as Oneflow participants. For example, in this case, we’re querying the Opportunity Contact Roles related to the record ID 006d2000000ELhcAAG.
  3. After that, you can assign values to the OneflowParticipant object fields using the records you fetched from Salesforce.If you’re working with multiple records, use a For Each loop to process them one by one. To learn more about the available fields in the OneflowParticipant object, refer to the official documentation: https://developer.oneflow.com/docs/participant.
  4. After that, add the populated object to the Apex-defined collection variable you created for PotentialParticipant.
  5. After that, you can pass the Apex-defined collection variable to the Participant Inputs field of the Create Contract action.



Creating a New Resource List of the Apex-Defined OneflowAttachment class objects.


  1. First, you need to create the necessary Apex-defined variables to hold the data. In this case, create an Apex-defined variable for a single OneflowAttachment, and an Apex-defined collection variable to store a list of OneflowAttachments. To create these variables, go to the Toolbox section in the Flow and click New Resource.
    1. How to create Apex-defined variable for  OneflowAttachment
      1. Resource Name → Variable
      2. API name → API name for the resource (Ex: OneflowAttachment)
      3. Data Type → Select Apex-Defined
      4. Apex Class → Select OFapp__OneflowAttachment from the drop down
      5. Check the Available for input checkbox
    2. How to create an Apex-defined collection variable for OneflowAttachment
      1. Follow the same steps as when creating an Apex-defined variable for OneflowAttachment, and make sure to check the Allow multiple values (collection) checkbox.
    3. You also need to create a collection variable to hold the Content Document IDs (Optional).

      Data Type → Text and Make sure to check the Allow multiple values (collection) checkbox.

  2. Next, you need to fetch the required ContentDocument records from Salesforce to assign values to the OneflowAttachment object.In this example, I’m fetching attachments linked to an Opportunity. First, we have to retrieve the ContentDocumentLink records related to the Opportunity ID and collect the related ContentDocument IDs. Then, fetch the ContentDocument records using those IDs and populate the OneflowAttachment object field values accordingly.
    Example
    1. You can fetch the ContentDocumentLinks by using the LinkedEntityId (the related record ID in Salesforce).
    2. Then, add the retrieved ContentDocument IDs to the collection variable you created earlier to store the Content Document IDs.
    3. Then, you can fetch the ContentDocuments using those IDs.
    4. After that, loop through the retrieved ContentDocuments and assign their values to the OneflowAttachment records. Required fields include: Title, Created Date, Description, File Extension, expand, and Size.
    5. Next, assign the OneflowAttachment object to the Apex-defined collection variable for OneflowAttachments.
  3. Finally, you can pass the Apex-defined collection variable to the Attachments Inputs field of the Create Contract action.





Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.