Create an Object Function Server Script

As an administrator, you must define the object function server script to be used by the Go to Microsoft Teams smart action to retrieve the Microsoft Teams URL associated with the record.

Here’s how to define the GoToTeams function server script in Application Composer.
  1. Navigate to Configuration > Sandboxes to create and enter a sandbox with Application Composer.
  2. From the sandbox, open Application Composer from the Tools menu.
  3. In Application Composer, expand the Standard Objects node, and then expand Opportunity.

    Note: You can also use these steps to create a team and access Microsoft Teams for other objects such as custom objects as well.
  4. Click Service Scripts as shown in this example screenshot.

    Screenshot highlighing the location of Server Scripts feature from the Opportunity object in Application Composer

  5. Click the Object Functions tab to display a screen similar to the following:

    Screenshot showing where you can edit your script on the Edit Object Function UI

  6. Enter required details as follows:
    • Function Name: GoToTeams
    • Returns: String
    • Visibility: Callable by External Systems
  7. Enter the following groovy sample code:
    def conn = adf.webServices.collaborations;
    try
    {
     def queryParams = ['q':'ObjectId='+OptyId]
     conn.dynamicQueryParams = queryParams
      def collabResponse = conn.GET() 
      def weburl = ""
      if (collabResponse.count > 0 ) { 
        weburl = collabResponse.items[0].Weburl;
      } 
      return weburl;
    }
     catch(Exception ex)
    {
     println(conn.statusCode+""); //for diagnostic logging
     println(conn.httpErrorResponse+""); //for diagnostic logging
     throw ex;
             }
    
    Note: You can copy the scripts provided to set up the integration for custom objects, but you must replace the OptyId value with the ID field for the custom object in all the sample scripts.
  8. Click Validate.
  9. Click Save and Close.