Platform Application Tutorial
- Overview
- Use Action UI for Platform
- Create the application wrapper
- Create the custom objects
- About the application
- Add fields to the objects
- Create the portal and pages
- Automatically send email
- Provide permission to access portal pages to the presenter
- Test the email trigger
- Create seed records
- Automatically create a statistical journal entry
- More extra credit?
- Export the application XML
- Delete or undeploy an application
- Challenge: Add an API trigger to create a sales order
- What’s Next?
Overview
An application is a wrapper around a group of objects, menus, and portals that work together to fulfill a function. You create a Platform application using the Sage Intacct UI.
Using Platform Services, you can create your own applications to efficiently handle unique processes for your company or other companies.
This tutorial shows you how to create a sample application that manages the attendees and presenters for company conferences. You will create custom data objects and then create menus, forms, pages, and workflows for those objects. After completing the tutorial, you will have a good understanding of the capabilities of Platform Services.
Application functionality
The sample application will track attendees and presenters for a company conference.
The end user for the application will be able to:
- Add attendees
- Assign corresponding customers
- Assign one of three conference levels
- Add conference presenters
- Assign corresponding customers
- Assign portal login IDs and passwords. (Portals are only supported in US locales.)
- Optionally modify seed records that provide conference pricing information
The application will have some automations:
- When a presenter is created, an email is sent to the presenter providing a login, password, and URL for uploading presentations
- When an attendee is added, a statistical journal entry is automatically created
The following shows the relationships between the application objects. Custom objects are prefaced by the MCA namespace, and the standard object is shown in green.
Building the application
Here’s an overview of how we will build the application:
-
Create the application wrapper.
-
Create custom objects for conference attendees, conference presenters, and conference price levels.
-
Create fields and relationships for each custom object.
-
Create a portal for presenters to upload presentations (only available in US locales).
-
Create a trigger for sending presenters their login credentials.
-
Create a trigger for creating a a statistical journal entry when attendees are added.
Important: You should not modify a sample application to build a production solution. Always build production applications from scratch in a clean development company without other custom applications and customizations. This ensures you only include what you intend in your application. Also, elements of an application are tied to the company where they were developed through ID numbers. It is better to create your objects in your own development company so you have consistent ID numbers.
Use Action UI for Platform
This tutorial uses the Action UI for Platform Services. You can enable this as follows:
-
From the upper right, click on your user name, then select My preferences.
-
Go to Personalize Platform and Customization Services, choose Action UI as the Layout type, then click Save.
Create the application wrapper
Let’s create the basic wrapper for the application. We will use a namespace to avoid potential name collisions with other third-party applications or Sage Intacct.
-
Go to Platform Services > Platform tools > + Applications.
-
On the Application Properties page that appears, leave This application is deployed checked.
This makes the application visible to end users, which lets us see the application menus and pages and test the functionality as we go.
-
Enter
MCA My Conferencing App
for the Application Name.End users will use this menu name to access the application. MCA is the namespace (short for My Conferencing App).
-
Click Save.
Your application is now listed under Custom Applications:
-
Click MCA My Conferencing App to open the Application Definition page.
The Application Definition page is where you do much of your work. It lets you create custom objects, menus, portals (only available in US locales), and so forth.
-
Click Edit Properties to look at the application properties.
There are sections for adding Custom Objects and Standard Objects to your application as well as other properties.
-
Click Cancel.
Create the custom objects
Now that we have the wrapper for our application, let’s add the three custom objects:
Attendee object
Let’s create the definition of the attendee object. We’ll use the best practice of providing a namespace for the object and tracking any changes for the audit log.
-
From the Application Definition page, click Objects in the banner:
If you need to get back to the Application Definition page, go to Platform Services > Platform tools > Applications and click MCA My Conferencing App.
-
Click New Object next Selected Objects.
-
On the Object Properties & Attributes page that appears, leave the Status Options unchecked.
-
Enter
Attendee
as the Singular Name for the object. -
Click outside the field and note that the other name fields are autofilled.
-
Change the Integration Name to
MCA_attendee
.Using the namespace is important for avoiding name collisions with other objects.
-
Under Optional Object Properties, select Audit Trail so there will be a history of when records of this type are created.
-
Further down, note that Create a new menu for this object and MCA My Conferencing App are checked, then click Save.
-
In the New Menu page that appears, note that MCA My Conferencing App is checked and click Save.
You are directed to a page that lists all Platform Services objects.
-
Scroll down and locate the new object. The ID number for your object will likely be different.
Conference level object
Let’s use a slightly different approach to create the next object. We’ll create the object first, then add it to the application afterwards.
-
Go to Platform Services > + Objects.
-
Enter
Conference Level
as the Singular Name for the object. -
Change the Integration Name to
MCA_conference_level
. -
Check the Audit Trail property.
-
Under Add to Applications, click MCA My Conferencing App, then click Save.
-
In the New Menu page that appears, click MCA My Conferencing App under Add to Applications and click Save.
Presenter object
We want the presenter to be able to log into a web page and upload their presentation to the system. There is a property that we can use to accomplish this.
-
Go to Platform Services > + Objects.
-
Enter
Presenter
as the Singular Name for the object. -
Change the Integration Name to
MCA_presenter
. -
Check the Audit Trail attribute.
-
Check the Portal Visitor attribute (only available in US locales).
This automatically adds login and password fields to the object.
-
Under Add to Applications, click MCA My Conferencing App, then click Save.
-
In the New Menu page that appears, click MCA My Conferencing App under Add to Applications and click Save.
About the application
Let’s confirm that the application is now available in the menus:
-
Reload your browser page.
-
Go to the Applications menu and choose MCA My Conference App to see the new menus:
As you continue to work on the application, you will access it in different ways. You can work from the Platform Service menus, like Platform Services > Objects or Platform Services > Platform tools > Applications. You can also access the definitions and properties for your custom objects from the end-user menus we looked at here. More on this later.
Permissions
As the application developer, we can see the application and its menus without setting any permissions. However, other users need permissions for this. How you approach this depends on whether your company has user-based or role-based permissions (see Role-based vs. user-based permissions in the Sage Intacct product help).
This example assumes user-based permissions. If you use role-based permissions, you can add a new role with the permissions and assign that role to a test user.
-
Locate or create a test user that you can log in as.
-
Go to Company > Admin > Users, then click on Subscriptions to the right of the user you want.
-
On the subscriptions page, click the checkbox for My Conference Application (near the bottom of the page).
-
On the same page, click Permissions to the right of My Conference Application
-
In the Permissions dialog that appears, grant the following permissions:
-
Click Save in the Permissions dialog, then click Save on the Subscriptions page.
-
(Optional) Log in as the test user and verify that you can see the application.
Tip: Be aware that when creating production applications for clients, you need to provide information about how end users set up their permissions for using the application.
Add fields to the objects
Now that we have our three objects, let’s create fields on the objects to provide the functionality we want.
Tip: Because we used namespaces for our custom objects, we are already protected from name collisions on fields—there is no need to use namespaces. However, keep in mind that when you add custom fields to standard objects, you should use namespaces.
Attendee fields
Recall that we need to add the following:
- Attendee name
- Customer (relationship)
- Conference level (relationship)
Create the Attendee name field
-
Go to Platform Services > Platform tools > Applications and click on MCA My Conference App.
-
In the shortcuts banner of the Application Definition page that appears, click Objects .
-
Under Selected Objects, click Attendee. (Click on Attendee, not Edit.)
This opens the Object Definition page.
-
Click Fields in the Component List Shortcuts banner.
Note that our object already has fields that were automatically added, such as Attendee, Comments, Created At, and so forth.
-
Click New Field at the top of the list.
-
Click Text for the type and click Next.
-
Enter Attendee name as the field label.
-
Check This field is required in all forms and click Save.
-
The Add to Pages and Views screen shows various pages (automatically provided by the system) so that end users can create attendees, edit, import, and so forth.
-
Click All Attendees under Views, then click Save.
Create the Email field
Let’s use a different approach to access the object definition this time.
-
From the main menus, go to MCA My Conferencing App > Attendees > Attendees.
-
Click Object Definition in the upper right of the lister page.
-
Click Fields in the Component List Shortcuts banner.
-
Click New Field at the top of the list.
-
Click Email for the type and click Next.
-
Enter Email as the field label.
-
Check This field is required in all forms and click Save.
-
In the Add to Pages and Views screen that appears, click Save to accept the defaults.
Create the relationship to customers
Now let’s add a relationship between our attendee object and the standard customer object so that attendees can be associated with existing customers.
-
From the Object Definition page for Attendee, click Relationships in the Component List Shortcuts banner.
-
Click New Relationship next to Relationships.
-
For the Related Object, click Customer [CUSTOMER], then click Next.
-
Leave the Singular and Plural Names as is.
Tip: Note that integration name for the relationship is not autofilled. You should provide an integration name with your relationships or the system will auto generate a name that is not intuitive.
-
Enter
R_attendee_customer
as the integration name.We use
R_
to identify the integration name as a relationship. -
For the Relationship Type, choose Many Attendees to One Customer.
A large company might send several attendees to the conference.
-
Leave the suggested Integration Names for the Lookup Fields as is (
RCUSTOMER
andRMCA_attendee
). -
Click Save.
Create the relationship to conference levels
Now lets add a relationship between MCA_attendee and MCA_conference_level
-
In the Object Definition page for Attendees, locate the Relationships section and click New Relationship.
-
For the Related Object, click Conference level [MCA_conference_level], then click Next.
-
Leave the Singular and Plural Names as is.
-
Enter
R_attendee_conference_level
as the Integration Name. -
For the Relationship Type, choose Many Attendees to One Conference Level.
Multiple attendees will register at the same conference level.
-
Leave the suggested Integration Names for the Lookup Fields as is (
RMCA_conference_level
andRMCA_attendee
). -
Click Save.
Unique record name
It’s recommended that you use unique names for record names, so let’s do that here:
-
From the Object Definition page for Attendee, click Edit Properties & Attributes.
-
In the Available Merge Fields section, select Attendee name from the drop down.
-
Copy the merge token that displays and paste it into the Record Name Template field.
-
Use Available Merge Fields again and select ID.
-
Copy the merge token and paste it into the Record Name Template field. Add two dashes between the tokens, as shown:
-
Click Save.
View the UI for creating new attendees
Let’s take a look at how users will apply these relationships now that we’ve laid the groundwork.
-
From the main menu, go to MCA My Conferencing App > Attendees > + Attendees.
-
Note that the Attendee field, which is the record name, is read only.
This is because the record name will be automatically generated using the record name template we provided.
-
Two of the fields are text entry, and the related Customer and Conference level can be chosen with lookups.
-
Click the magnifying glass next to Customer to show the form for choosing the related customer.
-
Close the Select Customer form, then click Cancel on the New Attendee page.
Conference level fields
Recall that we need to add the following:
- Price level
- Price
Create the Price Level and Price fields
-
Open the Object Definition page for Conference Level.
-
Go to the Fields section and add the following two new fields.
Field Type Field Label Field is required in all forms Add to Pages and Views Text Price level True Accept default values Currency Price True Accept default values -
Check This field is required in all forms and click Save.
-
(Optional) From the Object Definition page, click Edit Properties & Attributes and set up a unique record name template like this:
{!price_level!}--{!id!}
See the instructions for the attendee object if you need help.
Presenter fields
Recall that we need to add the following:
- Presenter name
- Active
- Presentation
Because the Presenter object was defined as a Portal Visitor at create time, the following fields are automatically available to use:
- Login Name
- Password
Create the fields
-
Open the object definition page for Presenter.
-
Scroll down to Fields and click New Field.
-
Go to the Fields section and add the following new fields—note that there are some options for these fields that we haven’t used yet, such as default value and file extension.
Field Type Field Label Field is required in all forms Add to Pages and Views Text Presenter name True Accept default values Field Type Field Label Default Value Add to Pages and Views Check Box Active Checked Accept default values Note: All custom objects have an
isActive
field that can be used for the same purpose as theActive
field we are adding.Field Type Field Label Field is required in all forms Add to Pages and Views Email Email True Accept default values Field Type Field Label File Extensions Add to Pages and Views File Upload Presentation .pdf Accept default values -
(Optional) From the Object Definition page, click Edit Properties & Attributes and set up a unique record name template like this:
{!presenter_name!}--{!id!}
See the instructions for the attendee object if you need help.
Extra credit - Create a relationship to customers
A presenter could certainly be a customer as well.
Using the steps above as a guide, create a comparable relationship from presenters to customers—use R_presenter_customer
as the integration name for the relationship.
View the UI for creating new presenters
Let’s look at how users will create a new presenter:
-
Go to the main menu and go to MCA My Conferencing App > Presenters > + Presenters.
Notice that the Login name and Password fields are not present.
This is because these two fields are automatically added to an object created as a Portal Visitor, but they are intended for use in a web page that presenters can use for uploading presentations. We are also going to add them to the page for creating a portal user though so we can assign them at creation time.
Important: Remember that this is a sample application not intended to be used in production. Providing portal visitor passwords must include extra security in production environments.
Add login and password fields to the New Presenter page
-
Still on the New Presenter page, click Edit this page on the upper right.
The Page Editor provides building blocks for the page on the left and the layout space for the page on the right.
-
Drag Login Name from Available Components to directly below Email on the right.
-
Drag Password to directly below Login Name.
This component automatically provides two text entry fields so the password can be verified when it is created.
-
If you completed the extra credit and have a relationship to the customer object, drag the Customer field below the password fields.
The page should look like this:
-
Click Save.
-
Go to the main menu and go to MCA My Conferencing App > Presenters > + Presenters again and verify that the two fields are present.
We’ll look at how to provide the login and password to the presenter via an email later.
The three objects for our application are now complete.
Create the portal and pages
We need to create a portal and some pages so that presenters can log in and upload their presentations. We also need a way to provide presenters with their login credentials.
Create a portal for external users (presenters)
-
Go to Platform Services > Platform tools > Applications > MCA My Conferencing App.
-
Scroll to Selected Portals and click New Portal.
-
Enter
Conference portal
for the Portal Name and for the Sub-Domain Name. -
Select Is Deployed and click Save.
Create a login page for presenters
-
Still on the Application Definition page, click Conference portal under Selected Portals to open the Portal Definition page.
-
Click New Page in the Pages section.
-
On the New Portal Page, enter
Presenter Login
for the Page Name. -
For the Page Type, click Login Form.
-
Choose Presenter for the Object Type, then click Save.
The Page Editor shows a page with login name and password:
-
Click Save.
We now have a login page, but we need to modify the portal so that this page is the first page presenters see.
-
Go to Platform Services > Platform Tools > Portals and click Conference portal.
-
Click Edit Properties.
-
For Main Page, choose Presenter Login and click Save.
-
Note the Main Page URL link, similar to the example below.
This link lets external users access the login page.
Create a page for uploading presentations
-
Still on the Portal Definition page, click New Page.
-
On the New Portal Page, enter
Upload Presentation (.pdf)
for the Page Name. -
Click Only logged in portal visitors can access this page.
-
For the Page Type, click Object Edit Page, then select Presenter as the Object Type.
The Object Edit Page type lets users modify an object, such as by uploading a presentation for a given presenter.
-
Click Save to display the page editor.
-
Drag (File Upload) Presentation from the left to directly below the Notification Message box.
-
Drag a New HTML Component from the left to directly above the logout link on the right.
-
Click Edit on the new component and add text like this:
-
Click Save.
Now we need to create a link from the login page to the file upload page.
-
Click Edit next to the Presenter Login page.
-
Click the Login Form box on the right to select it.
The Properties on the upper left change to display a Destination Page field.
-
Choose Upload Presentation (.pdf), then click Save.
Presenters will now be taken to the upload page after logging into the portal.
-
Click Save.
Automatically send email
Now that the portal pages are done, we need the ability to send presenters their login information.
We’ll create a trigger to send the email.
Create the Email Trigger
-
Still on the Presenter object definition, click Triggers in the Component List Shortcuts banner, then click New Trigger.
-
Set up the trigger:
-
For the Trigger Type, select Send Email and click Next.
-
Select This trigger is deployed.
-
Under Trigger Activation, choose After Create.
After creating a new presenter, the trigger will execute.
-
Enter
Presenter_Welcome
as the Trigger Name.
-
-
Under Trigger Type Properties, choose Email as the Use Field option.
Note that Send To is filled in with:
{!email!}
-
For Reply To, enter something like this:
noreply@nomail.com
-
Click the plus sign to the right of
Email Template
to add a new template. -
Provide
Presenter Welcome
as the Template Name. -
Enter
Thank you for being a presenter!
in the Subject field. -
Use a merge field to to include the name of the presenter in the email:
-
Under Available Merge Fields, choose Presenter, then choose Presenter name under the Select Field.
Note that the merge field shows this token:
{!MCA_presenter.presenter_name!}
-
Copy the the token, paste it into the text editor area, and preface it with a greeting:
Hello {!MCA_presenter.presenter_name!} --
This will look something like this in the sent email:
Hello Jen Jones --
-
-
Provide the presenter with the URL for the login page:
-
Under Available Merge Fields, choose Conference portal, then choose Presenter Login [link].
-
Copy the token and create a sentence like this:
Please log in to verify your credentials and upload your presentation: {!#PORTAL.162314@10004.162314@12547#link!}
-
-
Use merge fields to provide presenters with their login credentials:
-
Select Presenter as the merge field, choose Login Name, copy the merge field token, and paste it on a separate line at the bottom of the text editor area.
-
Do the same for Password.
-
Arrange text around the tokens as follows:
Login ID: {!MCA_presenter.loginName!} Password: {!MCA_presenter.password!}
-
-
Add a salutation at the end.
The complete message should look something like this:
-
Click Save at the bottom of the Email Template page, then click Save on the Trigger page.
Provide permission to access portal pages to the presenter
When you first create a portal, the system automatically creates a portal user identity. We need to make sure this user has the appropriate permissions to upload a presentation. In effect, the Portal User will modify a Presenter record in the system by adding a document to it.
-
Go to Company > Admin > Users, roles, & groups > External users and click Subscriptions in the Portal User row.
-
Scroll down, go to MCA My Conferencing App, and click Permissions.
-
Under Objects, click Edit for the Presenter object.
-
Click Save, then click Save again on the Company subscriptions page.
Test the email trigger
Let’s test things by creating a fictitious presenter.
-
Go to MCA My Conferencing App > Presenters > + Presenters.
-
Create a presenter, making sure to supply your own email address, for example:
Presenter name: Jen Jones Active: checked Customer: Email: your email address Login Name: tester Password: Welcome123_!
-
Save the presenter, then check your email and open the message from
noreply@nomail.com
. -
Click the Presenter Login link and use your login ID and password to log in.
-
On the upload page, click Choose File, select a test pdf file to upload, then click Submit.
-
Log out the user.
-
Go to MCA My Conference App > Presenters > Presenters to show the list of all presenters. Note the Presenter name, which is based on the record name template we used when defining the new presenter object.
-
Click on Jen Jones–xxxxx to view the presenter information:
Create seed records
It might be helpful to create seed records for the conference price levels. This way, users can modify these records to suit their needs instead of creating them from scratch.
We’ll create three price level records, each with a different price:
- Introductory
- Standard
- Premier
-
Go to the main menu and go to MCA My Conferencing App > Conference Level > + Conference Level.
-
On the page that appears, enter the following:
Price Level: Introductory Price: 1000
-
Click Save.
-
Repeat this for two more levels:
Price Level: Standard Price: 1500
Price Level: Premier Price: 2500
Now that we have our three levels, let’s add them to the application:
-
Go to Platform Services > Platform tools > Applications, then click MCA My Conferencing App.
-
Click Seed Records in the Component List Shortcuts banner, then click Attach Record.
-
In the dialog that appears, choose Conference Level from the dropdown.
-
Click on Premier, and note that the Application Definition page shows that the seed record was added in a banner message.
-
Click on the other two conference levels to add them, then click Close Window in the Attach Record dialog.
Let’s verify that the seed records are now available in the application:
-
Go to MCA My Conferencing App > Conference Levels > Conference Levels to open the list view:
Automatically create a statistical journal entry
API triggers provide a powerful mechanism for automating tasks.
Let’s assume we want to use an API trigger to keep a running tally of the number of conference registrations. Statistical journals are great for this purpose. A statistical journal entry simply increases or decreases a value—we can automatically create a statistical journal entry each time a new attendee is created.
Before we can create a statistical journal entry, we need to create a simple statistical account and a statistical journal we can use.
Create the statistical account
-
Go to General Ledger > All > + Statistical account.
-
Provide the following values, then slick Save.
Label Value Account number ATTD Title Conference attendance Report type Cumulative balance Status Active
Create the statistical journal
-
Go to General Ledger > Setup > + Statistical.
-
Provide the following values, then slick Save.
Label Value Symbol MCA-01 Title Conference attendance Status Active
Now we are ready to work on the function.
Create the API Trigger
Here’s an example of a function that creates a statistical journal entry:
<create>
<GLBATCH>
<JOURNAL>MCA-01</JOURNAL>
<BATCH_DATE>12/12/2019</BATCH_DATE>
<BATCH_TITLE>Conference registration</BATCH_TITLE>
<ENTRIES>
<GLENTRY>
<ACCOUNTNO>ATTD</ACCOUNTNO>
<TR_TYPE>1</TR_TYPE>
<AMOUNT>1</AMOUNT>
<DESCRIPTION>Registration for Jen Jones for $1000</DESCRIPTION>
</GLENTRY>
</ENTRIES>
</GLBATCH>
</create>
Note: If you are using a multi-entity company, you need to include <LOCATION>myLocationID</LOCATION>
for the GLENTRY
in the XML (see Create Journal Entry for details).
Because we are working inside Platform Services, we don’t need to include any of the header or footer information that is required for an XML request coming in from Web Services.
Let’s create a trigger that executes the function, which is stored as a document template.
-
On the Attendee object definition page banner, click Triggers, then click New Trigger.
-
Set up the trigger:
-
For the Trigger Type, choose Intacct API and click Next.
-
Select This trigger is deployed.
-
For Trigger Activation, click After Create.
-
For Trigger Name, enter
Create_Stat_Journal
.
-
-
Under Trigger Type Properties, click the plus sign to add a new document template.
-
Enter
Create registration stat journal
as the Template Name. -
Copy the
create
example above and paste it into the code editor area. -
Use a merge field to include the name of the attendee in the description:
-
From the Available Merge Fields, choose Attendee as the field type and Attendee name for the field. The token displays:
{!MCA_attendee.attendee_name!}
-
Copy and paste the token over the name in the
Description
element of the API function.
-
-
Use a merge field to include the conference price in the description:
-
From the Available Merge Fields, choose Related Conference level as the field type and Price for the field. The token displays:
{!R_attendee_conference_level.price!}
-
Copy and paste the token over the price in the
Description
element of the API function.
-
-
(Optional) Preview the document template with the merge fields filled in for a given attendee:
-
Click Preview Template.
-
In the Attendees Selector table, click on an attendee name to open the Preview.
(If you don’t yet have an attendee record, there won’t be a name to choose.)
-
Close the Preview template window.
-
-
Click Save in the Create Template window.
-
Scroll to the bottom of the New Trigger page and click Save.
Test the trigger
-
Choose MCA My Conferencing App > Attendees > + Attendee to create a new attendee.
-
Go to General Ledger > Setup > Statistical and click View Transactions for the Conference attendance journal.
-
Click on view for the transaction. You should see something like this:
Troubleshooting
If you don’t see an entry, it probably means there is an issue with the API call. Here are some troubleshooting suggestions.
-
Manually create a statistical journal entry for the Conference level journal in the UI. Are other fields required? For example, do you need to supply a location? If so, modify the API call in your Document Template (accessed from the Object Definition page for Attendee).
-
Try removing the merge fields in the Description and try again. If successful, you know that you need to look more closely at your merge fields to see if there are errors.
-
Confirm that you can create a statistical journal entry via the API. You can use Postman for this, as described in Your First XML API Calls.
More extra credit?
If you want a challenge, consider completing the section on creating a sales order with an API trigger. Otherwise, you can skip the challenge and go onto exporting your application’s XML below.
Export the application XML
The application is now complete. Let’s export the application’s XML, which is then available for installation into a target company.
-
Go to Platform Services > Platform tools > Applications > MCA My Conferencing App.
-
In the upper right, click Publish.
-
In the page that appears, note that the application name and version are filled in for you.
-
Also note that isManaged is not checked – this is only a sample application, so that’s fine.
Important: For a production application, the best choice is almost always a managed application. When an application is managed, it cannot be modified after it is installed. If you leave an application un-managed, users can make changes on the installed version, which makes it impossible to update without potential data loss.
-
Click Generate XML to download the application’s XML definition.
Important: You should never edit an application’s XML file.
The application can now be installed in a different company. Congratulations on creating your first Platform application!
If you want to install the application on a different development company, see Custom applications in the Sage Intacct product help.
Delete or undeploy an application
If you want to remove the sample application, you have two options:
- Undeploy it to hide it while retaining the option of restoring it later.
- Permanently delete the application after undeploying it.
Undeploy the application
-
Go to Platform Services > Platform tools > Applications.
A list of all applications appears.
-
Next to MCA My Conferencing App, click Edit.
-
On the Application Definition page, click Edit Properties.
-
On the Application Properties page, clear the This application is deployed checkbox, and click Save.
Delete the application
Before an application can be deleted, it must be undeployed for a period of time so that the system can update the status in the cache.
-
Undeploy the application as described above and wait a few minutes.
-
Go to Platform Services > Platform tools > Applications.
A list of all applications appears. If the application has been undeployed for long enough, it will look like this:
-
Next to MCA My Conferencing App, click Del, then confirm the action by clicking the checkbox and Delete.
Challenge: Add an API trigger to create a sales order
We can create a trigger that uses an API function to create a sales order for each new attendee. Your company must have subscriptions to Order Entry and Inventory Control to create a sales order. You must also have a mechanism for sending XML API calls via Web Services.
Note: If you don’t have these subscriptions, you can read through the steps to get an idea of how to create a transaction using an API trigger.
We will use the create_sotransaction
function, which will look something like this:
<create_sotransaction>
<transactiontype>Sales Order</transactiontype>
<datecreated>
<year>2019</year>
<month>3</month>
<day>27</day>
</datecreated>
<customerid>CUST-198</customerid>
<referenceno>Test</referenceno>
<datedue>
<year>2019</year>
<month>4</month>
<day>27</day>
</datedue>
<message>Jen Jones -- Thank you for registering for the conference!</message>
<state>Pending</state>
<sotransitems>
<sotransitem>
<itemid>Conference registration</itemid>
<quantity>1</quantity>
<unit>Each</unit>
<price>100</price>
</sotransitem>
</sotransitems>
</create_sotransaction>
We are going to use merge fields to grab the needed parameter values. Our attendee object provides these values, but not in the format required.
For example, an attendee record has Created At field with a Date/Time format. However, we need the date broken into year, month, and day for the function call. To address this, we need to add more fields to the object definition.
Create an Inventory Control item for the sales order
We need an item in Inventory Control for the conference level in order to be able to create a sales order. This is just a placeholder item for the purposes of the tutorial.
Note: Creating the conference price levels as Inventory Control items from the start would have worked as an alternative to creating a custom Conference level object. Using a custom object worked well for demonstration purposes for this tutorial.
-
Go to Inventory Control > All > + Items.
-
Enter
Conference registration
for the Item ID and Name. -
Choose any available Warehouse ID, then click Save.
Create a test sales order to confirm required fields
Different companies have different requirements for the parameters for create_sotransaction
. For example, you will have different customers in your test company, and a multi-entity company requires currency parameters. Before continuing, confirm that you can create a sales order with the API.
Note: The date due for the sales order has to be later than the date created.
-
Use Postman (or your preferred mechanism) for sending Web Services API functions to your company to verify a working
create_sotransaction
function. Use the example above as a model.If you need help, see Your First XML API Calls.
-
Save your working function, either in Postman or in a text editor.
-
Use another XML function call to list attendees:
<readByQuery> <object>MCA_Attendee</object> <fields>*</fields> <query/> <pagesize>100</pagesize> </readByQuery>
-
Note the format for the
createdAt
value:<createdAt>2019-12-13T17:28:49Z</createdAt>
Add Year created field
Let’s use the createdAt
field to get the pieces that we need for the create_sotransaction
function. Will will add formula fields to the Attendee object to accomplish this.
-
Open the Attendee object definition and locate the Fields section.
-
Create a field for accessing only the creation year.
-
Click New Field at the top of the list.
-
Click Formula for the type and click Next.
-
Enter Year created for the field label, and Integer for the Formula Return Type.
-
Enter the following JavaScript in the formula field. We are using a JavaScript UTC function (
getUTCFullYear
) so that time zones are handled.return new Date("{!MCA_attendee.createdAt!}").getUTCFullYear();
-
Click check it for errors to validate the formula.
-
Click the magnifying glass, and choose an existing attendee to see exactly what will be returned. The result at the bottom should show just the year.
-
Close the dialog, then click Save on the New Field page.
-
Accept the defaults for the Add to Pages and Views dialog.
-
Add Month created and Day created fields
-
Using the above instructions, create two more fields for Attendee as follows:
Field Type Field Label Formula Return Type Formula Pages and Views formula Month created Integer return new Date("{!MCA_attendee.createdAt!}").getUTCMonth() + 1;
Accept defaults formula Day created Integer return new Date("{!MCA_attendee.createdAt!}").getUTCDate();
Accept defaults Note: The
+1
for the month is to adjust for the fact the the Javascript getUTCMonth function returns January as 0, February is 1, and so forth.
Add Due date fields
Now we need to create three comparable fields for the pieces the comprise the date due for the sales order. Let’s use one month past the creation date as the due date.
Note that you could use a net term of 30 to accomplish the same task, but we are working through this exercise as a learning experience.
-
Create a new Year due formula field on the attendee object that returns an integer type and uses the following formula:
var d = new Date("{!MCA_attendee.createdAt!}"); d.setMonth(d.getUTCMonth() + 1); // Add one month return d.getUTCFullYear();
-
Create Month due and Day due fields:
Field Type Field Label Return Type Formula Pages and Views formula Month due Integer return new Date("{!MCA_attendee.createdAt!}").getUTCMonth() + 1;
Accept defaults formula Day due Integer return new Date("{!MCA_attendee.createdAt!}").getUTCDate();
Accept defaults
Create the API trigger
Now that the Attendee has the fields we need, let’s create a trigger for the API call.
-
On the Attendee object definition page banner, click Triggers, then click New Trigger.
-
Set up the trigger:
-
For the Trigger Type, choose Intacct API and click Next.
-
Select This trigger is deployed.
-
For Trigger Activation, click After Create.
-
For Trigger Name, enter
Create_Sales_Order
.
-
-
Under Trigger Type Properties, click the plus sign to add a new document template.
-
Enter
Conference registration sales order
as the Template Name. -
Paste your working
create_sotransaction
function (created above) into the code editor area. -
Use a merge field to include the year created for the date due:
-
Under Available Merge Fields, choose Attendee as the field type and Year created for the field. The token displays:
{!MCA_attendee.year_created!}
-
Copy and paste the token into the
year
child element ofdatecreated
into the code editor area.
-
-
Use the same approach for the
month
andday
elements:<month>{!MCA_attendee.month_created!}</month> <day>{!MCA_attendee.day_created!}</day>
-
Set up the
datedue
elements as follows:<datedue> <year>{!MCA_attendee.year_due!}</year> <month>{!MCA_attendee.month_due!}</month> <day>{!MCA_attendee.day_due!}</day> </datedue>
-
From the Available Merge Fields, choose Related Conference level, then set up the
price
element as follows:<price>{!R_attendee_conference_level.price!}</price>
-
From the Available Merge Fields, choose Attendee, then set up the
customerid
element as follows:<customerid>{!MCA_attendee.RCUSTOMER!}</customerid>
-
Provide the transaction type (must be a valid transaction type in the company):
<transactiontype>Sales Order</transactiontype>
-
Just to make it easy for us to find a sales order during our testing, use an easy-to-find field name for
referenceno
:<referenceno>ABC test</referenceno>
-
Fill in any other missing parameters and click Save.
Your completed call will look something like this:
<create_sotransaction> <transactiontype>Sales Order</transactiontype> <datecreated> <year>{!MCA_attendee.year_created!}</year> <month>{!MCA_attendee.month_created!}</month> <day>{!MCA_attendee.day_created!}</day> </datecreated> <customerid>A11</customerid> <referenceno>ABC test</referenceno> <datedue> <year>{!MCA_attendee.year_due!}</year> <month>{!MCA_attendee.month_due!}</month> <day>{!MCA_attendee.day_due!}</day> </datedue> <state>Pending</state> <sotransitems> <sotransitem> <itemid>Conference registration</itemid> <warehouseid>East</warehouseid> <quantity>1</quantity> <unit>Each</unit> <price>{!R_attendee_conference_level.price!}</price> </sotransitem> </sotransitems> </create_sotransaction>
-
Scroll to the bottom of the New Trigger page and click Save.
Test the trigger
-
Create a new attendee in the application.
-
Go to Order Entry > All > Sales Order and search for the new transaction by Reference number,
ABC test
.
Troubleshooting
If the Sales Order is not found, it means there was an issue with the API call. You can’t debug the call inside Platform Services, but you can use Postman to help figure out the problem:
-
Go back to your original working
create_sotransaction
call with the hard coded parameter values in Postman. -
Compare this version to the template version of the call and look for discrepancies.
-
If you don’t see any issues, begin replacing the merge-field values in the template with the appropriate hard-coded values from your working call. Each time you do this, upload the updated template and create another attendee. Repeat this until the sales order is created. This means the last replaced merge field was problematic.
What’s Next?
- Other script examples
- Platform Services in the Sage Intacct product help