When to use Write to Data Store Entity Smart Service and expression function a!writeToDataStoreEntity()

Hello everyone, my team and I are currently exploring writing our data into the database however, we are unsure if we should make use of the process model to write to db or the expression rule function a!writeToDataStoreEntity() provided by Appian. We read up the documentation but it doesnt really highlight the major differences or the preferred scenario to use either one of the methods. One major difference that we thought of is that if we make use of the smart service in the process model, a process instance will be created upon runtime which will essentially help us to track and debug in case any error occur. Does anyone know what are the differences and when is preferred use one over the other? 

  Discussion posts and replies are publicly visible

  • Calling the smart service as a function obfuscates application data flow at runtime and is much more difficult to debug. I would use the process node where possible. 

  • +1
    Certified Lead Developer

    Hi  

     If the use case is something where an external system calls an API exposed by Appian and the API needs to return a primary key or generated database key in response, using a!writeToDataStoreEntity() will be a good choice. 

    I assume you have an use case where there is a UI and the data input needs to be written into DB. The process instance will consume memory until the time of archival/deletion where as using a!writeToDataStoreEntity(), the consumed memory might be released as soon as the database write operation is completed. So in this aspect a!writeToDataStoreEntity() seems to be a preferable choice,  But if the use case has multiple data modification/manipulation after input data collected from UI, it is best to go with process model in order to track and debug the changes, however with a limited archival settings for the process. But if this is a simple DB write operation where we don't expect lot of data manipulation or any other simultaneous operation or where we know there are least chances things might go wrong, a!writeToDataStoreEntity is a good option.

     

     

  • I think the main way to decide is based on which type of interface you are using. For example, a task will always require using a process model, so it makes sense to perform the write to data store entity in the process model. However, if you want to write to the database from a report (for example, to save a filter value https://docs.appian.com/suite/help/latest/recipe-save-a-users-report-filters-to-data-store-entity.html), this is easier to use the smart service function because reports don't use a process model. So the rule of thumb to use is: if a process model is required by the type of interface you use (action / task forms), use the smart service in the PM; if the interface does not require a process (record / report dashboards), then use the smart service function.

    I think you will also find that most cases when you are saving data to the database involve using forms / processes because you will want to save to a database for completion, which means you will end up using the process model smart service quite a bit more often.

  • hello peter, thank you for your answer. i didnt factor in the type of interfaces as part of the consideration process and this indeed is a good point. thank you!

  • indeed that this is one of the biggest concerns we have. but we were thinking if using it in the process model is always the better way, why would appian provide the function option then

  • Hello Arjun. Thanks for the lengthy response! now tht you have laid out certain scenarios to which use is more ideal, its clearer to me now. It makes sense that data monitoring and tracking will be more ideal when the data is going to be manipulated down the process of a certain case. for now, the fucntion seems like the better option as we dont need data manipulation. hwoever another concern is, it states in Appian documentation that the function is an asycn process as compared to the smart servcie. in the event when the db writing operation is lagging and the interface refreshes, how would user know if the saving is being done correctly/the data reflected is the new changes?