Send email to task assignee by field event

Hi,

We have a customized task request application in Aras and I want to build a method to send assignee an email when the task has been assigned to the person.

I want to add the method to a field event, onChange. So, when the assignee changes value, an email will be sent. See attached screenshots.

And my code:

Innovator inn = this.getInnovator();
string str_body = "";

// Get assignee
string assignee = this.getProperty("dlv_assignedto","");

//Get Url
string str_actionID = this.getProperty("id","");
string str_actionReq = "DLV_ActionReq";
string link = string.Format(@"<html><p><a href=""{2}/Default.aspx?StartItem={0}:{1}"">Click here to open the ticket</a></p></html>",str_actionReq, str_actionID, CCO.Request.Url.ToString().Substring(0,CCO.Request.Url.ToString().IndexOf("/Server/")));

// Get Mail
Item email = inn.newItem("Email Message", "get");
email.setID("11A395B11B3A4337AE24F539266E815D");
email = email.apply();

email.setProperty("subject", string.Format("The following Action Request {0} has been assigned to you",this.getProperty("item_number","")));
str_body = string.Format(@"<html><B>The following Action Request {0} has been assigned to you. <br>{1} <br>Best regards,<br>Engineering Capability Office",this.getProperty("item_number",""), link);

email.setProperty("body_html", str_body);

// Get Identity for assignee
if ( assignee != "" ) {
string str_reqby = this.getPropertyAttribute("dlv_assignedto", "keyed_name");
Item iden = this.newItem("Identity", "get");
iden.setProperty("name", str_reqby);
iden = iden.apply();
if ( iden.getItemCount() == 1) { Boolean result = this.email(email, iden); }
}

return this;

---------------------------------------------------

Any idea why it does not work?

Have tried with server events, onAfterUpdate and it works. But not working with onAfterUnlock, it will solve my problem as well.

Best Regards,

Jimmi

Parents Reply Children
  • Hi Gopikrishnan,

    Thank you for your kindly reply!

    I did not get any error from Aras GUI, just did not get any email when using onAfterUnlock.

    But from the log file, I found following:

    <LOGFILE>
    <event time="2020-06-03 20:51:56Z" reason="soap_action" TickCount="113254250" dt="0" message="ApplyItem" />
    <event time="2020-06-03 20:51:56Z" reason="requestDom" TickCount="113254250" dt="0" />
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="">schemas.xmlsoap.org/.../">
    <SOAP-ENV:Body>
    <ApplyItem>
    <Item type="DLV_ActionReq" id="F9732A7FC25144A481100EDF91582DB1" action="unlock" />
    </ApplyItem>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    <event time="2020-06-03 20:51:56Z" reason="cachedriver-key" TickCount="113254265" dt="15" message="GetMethodFromCache:A1C22425BF134F46833FA6E8AAA21348:en" />
    <event time="2020-06-03 20:51:56Z" reason="cachedriver-value" TickCount="113254265" dt="0" message="Aras.Server.Core.CacheMethodInfo" />
    <event time="2020-06-03 20:51:56Z" reason="NewID" TickCount="113254265" dt="0" message="1563BFE4DA9245299CAD37B38DFF1BF6" />
    <event time="2020-06-03 20:51:56Z" reason="cachedriver-key" TickCount="113254500" dt="235" message="GetItemTypeIdFromCache:Email Message:en" />
    <event time="2020-06-03 20:51:56Z" reason="cachedriver-value" TickCount="113254500" dt="0" message="Aras.Server.Core.ItemTypeIdInfo" />
    <event time="2020-06-03 20:51:56Z" reason="cachedriver-key" TickCount="113254500" dt="0" message="GetServerEventsFromCache:F91DE6AE038A4CC8B53D47D5A7FA49FC:en" />
    <event time="2020-06-03 20:51:56Z" reason="cachedriver-value" TickCount="113254500" dt="0" message="Aras.Server.Core.MetaDataInfo.ServerEventsList" />
    <event time="2020-06-03 20:51:56Z" reason="cachedriver-key" TickCount="113254500" dt="0" message="GetRelListFromCache:F91DE6AE038A4CC8B53D47D5A7FA49FC:False:en" />
    <event time="2020-06-03 20:51:56Z" reason="cachedriver-value" TickCount="113254500" dt="0" message="Aras.Server.Core.RelTypesList" />
    <event time="2020-06-03 20:51:56Z" reason="cachedriver-key" TickCount="113254500" dt="0" message="AllowedPermissionsList:F91DE6AE038A4CC8B53D47D5A7FA49FC:en" />
    <event time="2020-06-03 20:51:56Z" reason="cachedriver-value" TickCount="113254500" dt="0" message="Aras.Server.Core.PermissionsList" />
    <event time="2020-06-03 20:51:56Z" reason="performance" TickCount="113254500" dt="0" message="250" />
    <event time="2020-06-03 20:51:56Z" reason="responseDom" TickCount="113254500" dt="0" />
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="">schemas.xmlsoap.org/.../">
    <SOAP-ENV:Body>
    <Result>
    <Item type="DLV_ActionReq" typeId="B860EC10B74C40C089BA76FC4C41B26C" id="F9732A7FC25144A481100EDF91582DB1">
    <classification>Internal</classification>
    <config_id keyed_name="ACT-00000015" type="DLV_ActionReq">F9732A7FC25144A481100EDF91582DB1</config_id>
    <created_by_id keyed_name="Admin: Jimmi Yang" type="User">17E2112E82C745DCA979A95EB4B030C2</created_by_id>
    <created_on>2020-06-02T16:23:38</created_on>
    <current_state name="Created" keyed_name="Created" type="Life Cycle State">70ADED32721B485982F4446B3B7CCB05</current_state>
    <dlv_assignedto keyed_name="Jimmi Yang" type="User">BA68B9B4A8AF4EA2B255B5D1AB0C9E25</dlv_assignedto>
    <dlv_create_edit_usr>0</dlv_create_edit_usr>
    <dlv_customer keyed_name="Admin: Jimmi Yang" type="User">17E2112E82C745DCA979A95EB4B030C2</dlv_customer>
    <dlv_description>fdgdfgsfsfdsdf</dlv_description>
    <dlv_effectmanual>1</dlv_effectmanual>
    <dlv_estwork>Hours</dlv_estwork>
    <dlv_ext_usr>0</dlv_ext_usr>
    <dlv_header>fgdfg update</dlv_header>
    <dlv_int_usr>0</dlv_int_usr>
    <dlv_prio>Low</dlv_prio>
    <dlv_requested_by keyed_name="Admin: Jimmi Yang" type="User">17E2112E82C745DCA979A95EB4B030C2</dlv_requested_by>
    <dlv_searchdata_usr>0</dlv_searchdata_usr>
    <dlv_status>Received</dlv_status>
    <dlv_taskcategory>Maintain Data</dlv_taskcategory>
    <dlv_upload_doc_usr>0</dlv_upload_doc_usr>
    <generation>1</generation>
    <id keyed_name="ACT-00000015" type="DLV_ActionReq">F9732A7FC25144A481100EDF91582DB1</id>
    <is_current>1</is_current>
    <is_released>0</is_released>
    <keyed_name>ACT-00000015</keyed_name>
    <major_rev>A</major_rev>
    <modified_by_id keyed_name="Admin: Jimmi Yang" type="User">17E2112E82C745DCA979A95EB4B030C2</modified_by_id>
    <modified_on>2020-06-03T14:36:35</modified_on>
    <new_version>1</new_version>
    <not_lockable>0</not_lockable>
    <permission_id keyed_name="DLV_New" type="Permission">80A688D56E2D42B0A210E0D083196B97</permission_id>
    <state>Created</state>
    <team_id keyed_name="DL Process" type="Team">915EAEE1BC2845848C6F551E2AADCC21</team_id>
    <item_number>ACT-00000015</item_number>
    </Item>
    </Result>
    <Message>
    <event name="ids_modified" value="F9732A7FC25144A481100EDF91582DB1" />
    </Message>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    <event time="2020-06-03 20:51:56Z" reason="soap_action" TickCount="113254562" dt="0" message="ApplyItem" />
    <event time="2020-06-03 20:51:56Z" reason="requestDom" TickCount="113254562" dt="0" />
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="">schemas.xmlsoap.org/.../">
    <SOAP-ENV:Body>
    <ApplyItem>
    <Item type="ItemType" action="get" select="id, name, label">
    <Relationships>
    <Item type="Morphae" action="get" select="id">
    <related_id>B860EC10B74C40C089BA76FC4C41B26C</related_id>
    </Item>
    </Relationships>
    </Item>
    </ApplyItem>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    <event time="2020-06-03 20:51:56Z" reason="performance" TickCount="113254562" dt="0" message="0" />
    <event time="2020-06-03 20:51:56Z" reason="responseDom" TickCount="113254562" dt="0" />
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="">schemas.xmlsoap.org/.../">
    <SOAP-ENV:Body>
    <SOAP-ENV:Fault xmlns:af="">www.aras.com/InnovatorFault">
    <faultcode>0</faultcode>
    <faultstring><![CDATA[No items of type ItemType found.]]></faultstring>
    <detail>
    <af:legacy_detail><![CDATA[No items of type ItemType found.]]></af:legacy_detail>
    <af:legacy_faultstring><![CDATA[No items of type 'ItemType' found using the criteria:
    <Item type="ItemType" action="get" select="id, name, label"><Relationships><Item type="Morphae" action="get" select="id"><related_id>B860EC10B74C40C089BA76FC4C41B26C</related_id></Item></Relationships></Item>
    ]]></af:legacy_faultstring>
    <af:legacy_faultactor> at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
    at System.Environment.get_StackTrace()
    at Aras.Server.Core.XML.SetErrorMessageImplementation(XmlDocument xmlDom, String faultCode, String faultString, String legacyFaultString, String stackTrace) in E:\Builds\Innovator_RELS11-0-SP12\6920-RELS11-0-SP12\Innovator.git\CompilableCode\Core\Xml\xml.cs:line 662
    at Aras.Server.Core.XML.Aras.Server.Core.IXml.SetErrorMessage(XmlDocument xmlDom, XmlQualifiedName faultCode, String faultString, String legacyFaultString) in E:\Builds\Innovator_RELS11-0-SP12\6920-RELS11-0-SP12\Innovator.git\CompilableCode\Core\Xml\xml.cs:line 195
    at Aras.Server.Core.GetItemProxy.SetNoItemsFoundFaultCode(XmlDocument dom, String itemTypeName, XmlNode criteriaNode) in E:\Builds\Innovator_RELS11-0-SP12\6920-RELS11-0-SP12\Innovator.git\CompilableCode\Core\GetItem\GetItem.cs:line 623
    at Aras.Server.Core.GetItemProxy.GetItem_DefaultImplementation(XmlElement item, XmlDocument inDom, XmlDocument outDom, ItemTypeInfo itemType, Boolean maxGeneration, Boolean forceIgnorePermissions, InnovatorDBCommandParameterCollection pars, Int32 curLevel, Int32 maxLevel) in E:\Builds\Innovator_RELS11-0-SP12\6920-RELS11-0-SP12\Innovator.git\CompilableCode\Core\GetItem\GetItem.cs:line 1734
    at Aras.Server.Core.GetItemProxy.GetItem_Implementation(XmlElement criteriaItem, Boolean maxGeneration, Int32 curLevel, Int32 maxLevel, Boolean forceIgnorePermissions, XmlDocument outDom) in E:\Builds\Innovator_RELS11-0-SP12\6920-RELS11-0-SP12\Innovator.git\CompilableCode\Core\GetItem\GetItem.cs:line 1628
    at Aras.Server.Core.GetItemProxy.GetItemInternal(XmlDocument itemDom, XmlDocument passedResponseDom) in E:\Builds\Innovator_RELS11-0-SP12\6920-RELS11-0-SP12\Innovator.git\CompilableCode\Core\GetItem\GetItem.cs:line 700
    at Aras.Server.Core.ApplyItemProxy.ApplyItem(XmlDocument&amp; inDom, AddItemImplementationAdditionalInfo additionalItemInfo, XmlDocument&amp; outDom) in E:\Builds\Innovator_RELS11-0-SP12\6920-RELS11-0-SP12\Innovator.git\CompilableCode\Core\ApplyItem.cs:line 562
    at Aras.Server.Core.ApplyItemProxy.Aras.Server.Core.IApplyItem.ApplyItem(XmlDocument inDom, XmlDocument outDom) in E:\Builds\Innovator_RELS11-0-SP12\6920-RELS11-0-SP12\Innovator.git\CompilableCode\Core\ApplyItem.cs:line 284
    at Aras.Server.Core.ApplySoapAction.Apply(String soapAction, XmlDocument inDom, XmlDocument outDom, Boolean securityCheck) in E:\Builds\Innovator_RELS11-0-SP12\6920-RELS11-0-SP12\Innovator.git\CompilableCode\Core\ApplySoapAction.cs:line 130
    at Aras.Server.Core.SoapActionRequestController.ProcessSoapAction(String soapAction, XmlDocument requestDom) in E:\Builds\Innovator_RELS11-0-SP12\6920-RELS11-0-SP12\Innovator.git\CompilableCode\Core\RequestControllers\SoapActionRequestController.cs:line 263
    at Aras.Server.Core.SoapActionRequestController.GetResponse() in E:\Builds\Innovator_RELS11-0-SP12\6920-RELS11-0-SP12\Innovator.git\CompilableCode\Core\RequestControllers\SoapActionRequestController.cs:line 105
    at Aras.Server.Core.SoapActionRequestController.ProcessRequest() in E:\Builds\Innovator_RELS11-0-SP12\6920-RELS11-0-SP12\Innovator.git\CompilableCode\Core\RequestControllers\SoapActionRequestController.cs:line 57
    at Aras.Server.Core.Startup.InnovatorServerMain() in E:\Builds\Innovator_RELS11-0-SP12\6920-RELS11-0-SP12\Innovator.git\CompilableCode\Core\Startup.cs:line 27
    at Aras.Web.Server.InnovatorServer.OnLoad(EventArgs e) in E:\Builds\Innovator_RELS11-0-SP12\6920-RELS11-0-SP12\Innovator.git\CompilableCode\Aras.Web.Server\InnovatorServer.cs:line 17
    at System.Web.UI.Control.LoadRecursive()
    at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    at System.Web.UI.Page.ProcessRequest()
    at System.Web.UI.Page.ProcessRequest(HttpContext context)
    at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
    at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
    at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously)
    at System.Web.HttpApplication.PipelineStepManager.ResumeSteps(Exception error)
    at System.Web.HttpApplication.BeginProcessRequestNotification(HttpContext context, AsyncCallback cb)
    at System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context)
    at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
    at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
    at System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr pHandler, RequestNotificationStatus&amp; notificationStatus)
    at System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr pHandler, RequestNotificationStatus&amp; notificationStatus)
    at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
    at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)</af:legacy_faultactor>
    </detail>
    </SOAP-ENV:Fault>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    <event time="2020-06-03 20:51:56Z" reason="soap_action" TickCount="113254750" dt="0" message="ApplyItem" />
    <event time="2020-06-03 20:51:56Z" reason="requestDom" TickCount="113254750" dt="0" />
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="">schemas.xmlsoap.org/.../">
    <SOAP-ENV:Body>
    <ApplyItem>
    <Item type="DLV_ActionReq_File" action="get" page="1" select="id,created_by_id,created_on,modified_by_id,modified_on,locked_by_id,major_rev,css,current_state,keyed_name,related_id(comments,file_type,indexed_on,created_by_id,created_on,modified_by_id,modified_on,locked_by_id,major_rev,css,current_state,keyed_name),source_id" pagesize="" returnMode="itemsOnly">
    <source_id condition="eq">F9732A7FC25144A481100EDF91582DB1</source_id>
    </Item>
    </ApplyItem>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    <event time="2020-06-03 20:51:56Z" reason="performance" TickCount="113254765" dt="15" message="15" />
    <event time="2020-06-03 20:51:56Z" reason="responseDom" TickCount="113254765" dt="0" />
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="">schemas.xmlsoap.org/.../">
    <SOAP-ENV:Body>
    <SOAP-ENV:Fault xmlns:af="">www.aras.com/InnovatorFault">
    <faultcode>0</faultcode>
    <faultstring><![CDATA[No items of type DLV_ActionReq_File found.]]></faultstring>
    <detail>
    <af:legacy_detail><![CDATA[No items of type DLV_ActionReq_File found.]]></af:legacy_detail>
    <af:legacy_faultstring><![CDATA[No items of type 'DLV_ActionReq_File' found using the criteria:
    <Item type="DLV_ActionReq_File" action="get" page="1" select="id,created_by_id,created_on,modified_by_id,modified_on,locked_by_id,major_rev,css,current_state,keyed_name,related_id(comments,file_type,indexed_on,created_by_id,created_on,modified_by_id,modified_on,locked_by_id,major_rev,css,current_state,keyed_name),source_id" pagesize="" returnMode="itemsOnly"><source_id condition="eq">F9732A7FC25144A481100EDF91582DB1</source_id></Item>
    ]]></af:legacy_faultstring>
    <af:legacy_faultactor> at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
    at System.Environment.get_StackTrace()
    at Aras.Server.Core.XML.SetErrorMessageImplementation(XmlDocument xmlDom, String faultCode, String faultString, String legacyFaultString, String stackTrace) in E:\Builds\Innovator_RELS11-0-SP12\6920-RELS11-0-SP12\Innovator.git\CompilableCode\Core\Xml\xml.cs:line 662
    at Aras.Server.Core.XML.Aras.Server.Core.IXml.SetErrorMessage(XmlDocument xmlDom, XmlQualifiedName faultCode, String faultString, String legacyFaultString) in E:\Builds\Innovator_RELS11-0-SP12\6920-RELS11-0-SP12\Innovator.git\CompilableCode\Core\Xml\xml.cs:line 195
    at Aras.Server.Core.GetItemProxy.SetNoItemsFoundFaultCode(XmlDocument dom, String itemTypeName, XmlNode criteriaNode) in E:\Builds\Innovator_RELS11-0-SP12\6920-RELS11-0-SP12\Innovator.git\CompilableCode\Core\GetItem\GetItem.cs:line 623
    at Aras.Server.Core.GetItemProxy.GetItem_DefaultImplementation(XmlElement item, XmlDocument inDom, XmlDocument outDom, ItemTypeInfo itemType, Boolean maxGeneration, Boolean forceIgnorePermissions, InnovatorDBCommandParameterCollection pars, Int32 curLevel, Int32 maxLevel) in E:\Builds\Innovator_RELS11-0-SP12\6920-RELS11-0-SP12\Innovator.git\CompilableCode\Core\GetItem\GetItem.cs:line 1734
    at Aras.Server.Core.GetItemProxy.GetItem_Implementation(XmlElement criteriaItem, Boolean maxGeneration, Int32 curLevel, Int32 maxLevel, Boolean forceIgnorePermissions, XmlDocument outDom) in E:\Builds\Innovator_RELS11-0-SP12\6920-RELS11-0-SP12\Innovator.git\CompilableCode\Core\GetItem\GetItem.cs:line 1628
    at Aras.Server.Core.GetItemProxy.GetItemInternal(XmlDocument itemDom, XmlDocument passedResponseDom) in E:\Builds\Innovator_RELS11-0-SP12\6920-RELS11-0-SP12\Innovator.git\CompilableCode\Core\GetItem\GetItem.cs:line 700
    at Aras.Server.Core.ApplyItemProxy.ApplyItem(XmlDocument&amp; inDom, AddItemImplementationAdditionalInfo additionalItemInfo, XmlDocument&amp; outDom) in E:\Builds\Innovator_RELS11-0-SP12\6920-RELS11-0-SP12\Innovator.git\CompilableCode\Core\ApplyItem.cs:line 562
    at Aras.Server.Core.ApplyItemProxy.Aras.Server.Core.IApplyItem.ApplyItem(XmlDocument inDom, XmlDocument outDom) in E:\Builds\Innovator_RELS11-0-SP12\6920-RELS11-0-SP12\Innovator.git\CompilableCode\Core\ApplyItem.cs:line 284
    at Aras.Server.Core.ApplySoapAction.Apply(String soapAction, XmlDocument inDom, XmlDocument outDom, Boolean securityCheck) in E:\Builds\Innovator_RELS11-0-SP12\6920-RELS11-0-SP12\Innovator.git\CompilableCode\Core\ApplySoapAction.cs:line 130
    at Aras.Server.Core.SoapActionRequestController.ProcessSoapAction(String soapAction, XmlDocument requestDom) in E:\Builds\Innovator_RELS11-0-SP12\6920-RELS11-0-SP12\Innovator.git\CompilableCode\Core\RequestControllers\SoapActionRequestController.cs:line 263
    at Aras.Server.Core.SoapActionRequestController.GetResponse() in E:\Builds\Innovator_RELS11-0-SP12\6920-RELS11-0-SP12\Innovator.git\CompilableCode\Core\RequestControllers\SoapActionRequestController.cs:line 105
    at Aras.Server.Core.SoapActionRequestController.ProcessRequest() in E:\Builds\Innovator_RELS11-0-SP12\6920-RELS11-0-SP12\Innovator.git\CompilableCode\Core\RequestControllers\SoapActionRequestController.cs:line 57
    at Aras.Server.Core.Startup.InnovatorServerMain() in E:\Builds\Innovator_RELS11-0-SP12\6920-RELS11-0-SP12\Innovator.git\CompilableCode\Core\Startup.cs:line 27
    at Aras.Web.Server.InnovatorServer.OnLoad(EventArgs e) in E:\Builds\Innovator_RELS11-0-SP12\6920-RELS11-0-SP12\Innovator.git\CompilableCode\Aras.Web.Server\InnovatorServer.cs:line 17
    at System.Web.UI.Control.LoadRecursive()
    at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    at System.Web.UI.Page.ProcessRequest()
    at System.Web.UI.Page.ProcessRequest(HttpContext context)
    at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
    at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
    at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously)
    at System.Web.HttpApplication.PipelineStepManager.ResumeSteps(Exception error)
    at System.Web.HttpApplication.BeginProcessRequestNotification(HttpContext context, AsyncCallback cb)
    at System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context)
    at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
    at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
    at System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr pHandler, RequestNotificationStatus&amp; notificationStatus)
    at System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr pHandler, RequestNotificationStatus&amp; notificationStatus)
    at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
    at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)</af:legacy_faultactor>
    </detail>
    </SOAP-ENV:Fault>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    <event time="2020-06-03 20:51:56Z" reason="soap_action" TickCount="113254890" dt="0" message="applyaml" />
    <event time="2020-06-03 20:51:56Z" reason="requestDom" TickCount="113254890" dt="0" />
    <AML>
    <Item type="RelationshipType" action="get" select="name,label,auto_search,copy_permissions,core,default_page_size,description,grid_view,hide_in_all,inc_rel_key_name,inc_related_key_name,is_list_type,max_occurs,min_occurs,new_show_related,related_notnull,related_option,create_related,use_src_access,source_id,relationship_id,related_id" related_expand="0" isCriteria="0">
    <id>Parameters</id>
    <Relationships>
    <Item type="Relationship View" action="get" select="form,grid,start_page,parameters,related_id" related_expand="0" isCriteria="0" />
    <Item type="Relationship Grid Event" action="get" select="grid_event,related_id(name,method_type,method_code)" isCriteria="0" />
    </Relationships>
    </Item>
    </AML>
    <event time="2020-06-03 20:51:56Z" reason="soap_action" TickCount="113254937" dt="0" message="ApplyItem" />
    <event time="2020-06-03 20:51:56Z" reason="requestDom" TickCount="113254937" dt="0" />
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="">schemas.xmlsoap.org/.../">
    <SOAP-ENV:Body>
    <ApplyItem>
    <Item isNew="1" isTemp="1" type="SQL" action="DLV_COUNTS_ON_TABS_SERVER">
    <relshipTypeName>DLV_ActionReq_File|DLV_ActionReq_ActionReq|DLV_ActionReq_RefBy|DLV_ActionReq_Subscribers|DLV_ActionReq_User</relshipTypeName>
    <id>F9732A7FC25144A481100EDF91582DB1</id>
    </Item>
    </ApplyItem>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    <event time="2020-06-03 20:51:56Z" reason="SQL Process inDom" TickCount="113254937" dt="0" />
    <Item isNew="1" isTemp="1" type="SQL" action="SQL PROCESS">
    <name>dlv_cnt_tab_rels</name>
    <PROCESS>CALL</PROCESS>
    <ARG1>F9732A7FC25144A481100EDF91582DB1</ARG1>
    <ARG2>DLV_ActionReq_File|DLV_ActionReq_ActionReq|DLV_ActionReq_RefBy|DLV_ActionReq_Subscribers|DLV_ActionReq_User</ARG2>
    </Item>
    <event time="2020-06-03 20:51:56Z" reason="SQL Process db_item" TickCount="113254937" dt="0" />
    <Item isNew="1" isTemp="1" type="SQL" action="SQL PROCESS">
    <name>dlv_cnt_tab_rels</name>
    <PROCESS>CALL</PROCESS>
    <ARG1>F9732A7FC25144A481100EDF91582DB1</ARG1>
    <ARG2>DLV_ActionReq_File|DLV_ActionReq_ActionReq|DLV_ActionReq_RefBy|DLV_ActionReq_Subscribers|DLV_ActionReq_User</ARG2>
    </Item>
    <event time="2020-06-03 20:51:56Z" reason="SQL Process outDom" TickCount="113254937" dt="0" />
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="">schemas.xmlsoap.org/.../">
    <SOAP-ENV:Body>
    <Result>
    <Item>
    <ant>0|0|0|0|0|</ant>
    </Item>
    </Result>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    <event time="2020-06-03 20:51:56Z" reason="performance" TickCount="113254937" dt="0" message="0" />
    <event time="2020-06-03 20:51:56Z" reason="responseDom" TickCount="113254937" dt="0" />
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="">schemas.xmlsoap.org/.../">
    <SOAP-ENV:Body>
    <Result>
    <Item>
    <ant>0|0|0|0|0|</ant>
    </Item>
    </Result>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

  • Hi Gopkrishnan,

    Thank you for your kindly reply.

    I did not get any error message, but did not get any email with onAfterUnlock by some reason. Did you make any modification from my code above?

    BR,

    Jimmi

  • Below method should work. My changes are highlighted below

    Innovator inn = this.getInnovator();
    string str_body = "";

    // Get assignee
    Item thisItem = inn.newItem(this.getType(), "get");
    thisItem.setAttribute("select", "dlv_assignedto");
    thisItem.setID(this.getID());
    thisItem = thisItem.apply();
    string assignee = thisItem.getProperty("dlv_assignedto","");

    //Get Url
    string str_actionID = this.getProperty("id","");
    string str_actionReq = "DLV_ActionReq";
    string link = string.Format(@"<html><p><a href=""{2}/Default.aspx?StartItem={0}:{1}"">Click here to open the ticket</a></p></html>",str_actionReq, str_actionID, CCO.Request.Url.ToString().Substring(0,CCO.Request.Url.ToString().IndexOf("/Server/")));

    // Get Mail
    Item email = inn.newItem("Email Message", "get");
    email.setID("11A395B11B3A4337AE24F539266E815D");
    email = email.apply();

    email.setProperty("subject", string.Format("The following Action Request {0} has been assigned to you",this.getProperty("item_number","")));
    str_body = string.Format(@"<html><B>The following Action Request {0} has been assigned to you. <br>{1} <br>Best regards,<br>Engineering Capability Office",this.getProperty("item_number",""), link);

    email.setProperty("body_html", str_body);

    // Get Identity for assignee
    if ( assignee != "" ) {
    string str_reqby = thisItem.getPropertyAttribute("dlv_assignedto", "keyed_name");
    Item iden = this.newItem("Identity", "get");
    iden.setProperty("name", str_reqby);
    iden = iden.apply();
    if ( iden.getItemCount() == 1) { Boolean result = this.email(email, iden); }
    }

    return this;

    Thank You

    Gopikrishnan R

  • Thank you for your help! 

    The finally code:

    //return inn.newError(string.Format(str_reqby)); //Debugg code

    Innovator inn = this.getInnovator();
    string str_body = "";

    // Get assignee
    Item thisItem = inn.newItem(this.getType(), "get");
    thisItem.setAttribute("select", "dlv_assignedto");
    thisItem.setID(this.getID());
    thisItem = thisItem.apply();
    string assignee = thisItem.getProperty("dlv_assignedto","");
    //return inn.newError(string.Format(assignee));

    //Get Url
    Item thisItem2 = inn.newItem(this.getType(), "get");
    thisItem2.setAttribute("select", "item_number");
    thisItem2.setID(this.getID());
    thisItem2 = thisItem2.apply();
    string str_actionID = thisItem2.getProperty("item_number","");
    string str_actionReq = "DLV_ActionReq";
    string link = string.Format(@"<html><p><a href=""{2}/Default.aspx?StartItem={0}:{1}"">Click here to open the ticket</a></p></html>",str_actionReq, str_actionID, CCO.Request.Url.ToString().Substring(0,CCO.Request.Url.ToString().IndexOf("/Server/")));

    // Get Mail
    Item email = inn.newItem("Email Message", "get");
    email.setID("1241FA3032B3483786BC8DDD0DDF7394"); //DLV_ActionReq_Assignment
    email = email.apply();

    email.setProperty("subject", string.Format("The following Action Request {0} has been assigned to you",str_actionID));
    str_body = string.Format(@"<html><B>The following Action Request {0} has been assigned to you. <br>{1} <br>Best regards,<br>Engineering Capability Office",str_actionID, link);

    email.setProperty("body_html", str_body);

    // Get Identity for assignee
    if ( assignee != "" ) {
    Item userItem = this.newItem("User","get");
    userItem.setID(assignee);
    userItem.setAttribute("select","first_name,last_name");
    userItem = userItem.apply();
    string username = (userItem.getProperty("first_name") + " " + userItem.getProperty("last_name"));
    //return inn.newError(string.Format(username));
    Item iden = this.newItem("Identity", "get");
    iden.setProperty("name", username);
    iden = iden.apply();
    if ( iden.getItemCount() == 1) { Boolean result = this.email(email, iden); }
    }

    return this;

  • Hi Jimmi

    I have few suggestions for you.

    1. Based on your method, it seems you are doing apply action for 5 times but it can be reduced to 3 server calls. lesser the server call, more the application performance. 

    2. It is good practice to use the user ID to get the identity than using the user's first name and last name. If first name and last name is modified this method won't work. 

    3. Since on after unlock event is triggered on every unlock, the mail will trigger two times (assuming DLV is versionable) when you edit an existing item. 

    Example : I have one DLV item with generation 1. If I edit then it will change to generation 2. So, when I click Unlock, this will unlock generation 1 and generation 2. So method will trigger two time (one for old dlv assigned to another for new dlv assigned to).

    This wont be a problem if DLV is not versionable and always have one generation

    Based on above suggestions, Modified code is below

    Innovator inn = this.getInnovator();
    string str_body = "";

    // Get existing assignee
    string existingassignee = this.getProperty("dlv_assignedto","");

    // Get assignee
    Item thisItem = inn.newItem(this.getType(), "get");
    thisItem.setAttribute("select", "dlv_assignedto,item_number");
    thisItem.setID(this.getID());
    thisItem = thisItem.apply();
    string assignee = thisItem.getProperty("dlv_assignedto","");

    if(existingassignee == assignee)
    {
    return this;
    }

    //Get Url
    string str_actionID = thisItem.getProperty("item_number","");
    string str_actionReq = "DLV_ActionReq";
    string link = string.Format(@"<html><p><a href=""{2}/Default.aspx?StartItem={0}:{1}"">Click here to open the ticket</a></p></html>",str_actionReq, str_actionID, CCO.Request.Url.ToString().Substring(0,CCO.Request.Url.ToString().IndexOf("/Server/")));

    // Get Mail
    Item email = inn.newItem("Email Message", "get");
    email.setID("35DF32E58F02491B99B0450DA70AF85E"); //DLV_ActionReq_Assignment
    email = email.apply();

    email.setProperty("subject", string.Format("The following Action Request {0} has been assigned to you",str_actionID));
    str_body = string.Format(@"<html><B>The following Action Request {0} has been assigned to you. <br>{1} <br>Best regards,<br>Engineering Capability Office",str_actionID, link);

    email.setProperty("body_html", str_body);

    // Get Identity for assignee
    if ( assignee != "" )
    {
    Item userItem = inn.newItem("User", "get");
    userItem.setAttribute("select", "id");
    Item aliasItem = inn.newItem("Alias", "get");
    aliasItem.setAttribute("select", "related_id");
    Item identity = inn.newItem("Identity", "get");
    aliasItem.setPropertyItem("related_id", identity);
    userItem.addRelationship(aliasItem);
    userItem.setID(assignee);
    userItem = userItem.apply();
    if (userItem.isError())
    {
    return userItem;
    }
    aliasItem = userItem.getRelationships("Alias");
    Item iden = aliasItem.getItemByIndex(0).getRelatedItem();
    if (iden.getItemCount() == 1)
    {
    Boolean result = this.email(email, iden);
    }
    }
    return this;

    Thank You

    Gopikrishnan R

  • Hi Gopikrishnan,

    The following condition does not work, since existingassignee returns empty. 

    if(existingassignee == assignee)
    {
    return this;
    }

    Any other idea how to check if assignee changes or not? Right now, an email will be sent OnAfterUnlock, even though the assignee is not changed.

    BR,

    Jimmi

  • Hi Yanjim

    I would propose some other solution than the one on After Unlock event. 

    Follow below steps

    1. Create new JavaScript method (name : ARAS_Community_JS)and add below code 

    Update Server Method Name below ARAS_Community_Server

    var dlvAssignedTo = document.thisItem.getProperty('dlv_assignedto');
    if (dlvAssignedTo)
    {
    if (!top.aras.confirm('Do you want to send mail to DLV Assigned to User ?'))
    {
    return;
    }
    var callServerMethod = aras.IomInnovator.newItem('Method', 'ARAS_Community_Server');
    callServerMethod.setProperty('dlv_assignedto', dlvAssignedTo);
    callServerMethod.setProperty('item_number', document.thisItem.getProperty('item_number'));
    var result = callServerMethod.apply();
    if (result.isError())
    {
    aras.AlertError(result.getErrorString());
    }
    else
    {
    aras.AlertSuccess('Email sent successfully.');
    }
    }

    2. Update your existing server method with below code

    Innovator inn = this.getInnovator();
    string str_body = "";

    // Get assignee
    string assignee = this.getProperty("dlv_assignedto","");

    //Get Url
    string str_actionID = this.getProperty("item_number","");
    string str_actionReq = "DLV_ActionReq";
    string link = string.Format(@"<html><p><a href=""{2}/Default.aspx?StartItem={0}:{1}"">Click here to open the ticket</a></p></html>",str_actionReq, str_actionID, CCO.Request.Url.ToString().Substring(0,CCO.Request.Url.ToString().IndexOf("/Server/")));

    // Get Mail
    Item email = inn.newItem("Email Message", "get");
    email.setID("35DF32E58F02491B99B0450DA70AF85E"); //DLV_ActionReq_Assignment
    email = email.apply();

    email.setProperty("subject", string.Format("The following Action Request {0} has been assigned to you",str_actionID));
    str_body = string.Format(@"<html><B>The following Action Request {0} has been assigned to you. <br>{1} <br>Best regards,<br>Engineering Capability Office",str_actionID, link);

    email.setProperty("body_html", str_body);

    // Get Identity for assignee
    if ( assignee != "" )
    {
    Item userItem = inn.newItem("User", "get");
    userItem.setAttribute("select", "id");
    Item aliasItem = inn.newItem("Alias", "get");
    aliasItem.setAttribute("select", "related_id");
    Item identity = inn.newItem("Identity", "get");
    aliasItem.setPropertyItem("related_id", identity);
    userItem.addRelationship(aliasItem);
    userItem.setID(assignee);
    userItem = userItem.apply();
    if (userItem.isError())
    {
    return userItem;
    }
    aliasItem = userItem.getRelationships("Alias");
    Item iden = aliasItem.getItemByIndex(0).getRelatedItem();
    if (iden.getItemCount() == 1)
    {
    Boolean result = this.email(email, iden);
    }
    }
    return this;

    3. Open form where this dlv_assignedto property exist

    4. Add Form field event on dlv_assignedto property (Method Name : ARAS_Community_JS and event : On Change)

    5. Save and Unlock Form

    6. Try testing.

    Expected Result:

    Whenever the dlv_assigned_to field is changed, it will ask for confirmation from user whether to send email to user, if user select Ok, then it will send email else it will not send email

  • Hi Gopikrishnan,

    Thank you for your engagement and time! Appreciate it, really!

    The code works with following small issues:

    1. The confirm dialog appears twice each time dlv_assigned_to field is changed, does it need a delay somehow?

    2. When the dlv_assigned_to changes by search dialog (... button), the confirm dialog will not appear. Bug?

    BR,

    Jimmi