Question

Filter on Predict field values for Case

Hello, 

Dear community, 

 

I want to know how can I do the following thing : 

I've synchronized my mailbox, and when I receive a mail, a case is created automatically, but I want to create a filter. 

Create a case with all mail received on my mailbox except those which have as a subject the word "Test :"

 

I've tried to make a filter in a process, the Predict field values for Case process 

But it doesn't work. 

 

Linked to this post, I join several pictures in order to have a better understanding of my question. 

 

Thanks a lot

Best regards 

 

Like 0

Like

1 comments

Cases from emails are created in the process "Incoming email registration process". To not to create a case from the email with Test in subject you would need to change a script task a little. For example like that: 

try {

    _log.InfoFormat(@"[EmailSyncSessionId:{0}]|Process was started", Get<Guid>("RecordId"));

    lock (_syncLock) {

        Guid recordId = Get<Guid>("RecordId");

        var userConnection = Get<UserConnection>("UserConnection");

        var emailsList = GetActivityRecordsId(recordId);

        foreach (var email in emailsList) {

            _log.InfoFormat(@"[EmailSyncSessionId:{1}]|Start register case for ActivityId:{0}", email.ActivityId, Get<Guid>("RecordId"));

            try {

                var id_of_activity = email.ActivityId;

                

                var result = "";

                var selectQuery = new Select(userConnection)

                                    .Column("Title")

                                    .From("Activity")

                                    .Where("Id").IsEqual(Column.Parameter(id_of_activity)) as Select;

                result = selectQuery.ExecuteScalar<String>();

                

                if(email.CaseId == default(Guid)) {

                    if (!result.Contains("Test"))

                    {

                        email.CaseId = RegisterIncidentFromEmail(email.ActivityId);

                        if(email.CaseId != default(Guid)) {

                            var parentEmails = emailsList.Where(emailRecord =>

                                 emailRecord.ParentMessageId == email.Id);

                            foreach(var parentEmail in parentEmails) {

                                parentEmail.CaseId = email.CaseId;

                                var schema = userConnection.EntitySchemaManager.FindInstanceByName("Activity");

                                Entity entity = schema.CreateEntity(userConnection);

                                if (entity.FetchFromDB(parentEmail.ActivityId)) {

                                     entity.SetColumnValue("CaseId", email.CaseId);

                                    _log.InfoFormat(@"[EmailSyncSessionId:{1}]| Case was created during this process activity with ActivityId:{0},

                                    set CaseId:{2}", parentEmail.ActivityId, Get<Guid>("RecordId"), parentEmail.CaseId);

                                    entity.Save(false);

                                }

                            }

                        }

                    }

                }

            } catch (Exception ex) {

                _log.ErrorFormat(@"[EmailSyncSessionId:{0}]| Message: {1}, CallStack: {2}, InnerException: {3}",

                    Get<Guid>("RecordId"), ex.Message, ex.StackTrace, ex.InnerException);

            }

            _log.InfoFormat(@"[EmailSyncSessionId:{1}]|End register case for ActivityId:{0}", email.ActivityId, Get<Guid>("RecordId"));

        }

    }

    _log.InfoFormat(@"[EmailSyncSessionId:{0}]|Process was finished", Get<Guid>("RecordId"));

} catch (Exception ex) {

                _log.ErrorFormat(@"[EmailSyncSessionId:{0}]| Message: {1}, CallStack: {2}, InnerException: {3}",

                    Get<Guid>("RecordId"), ex.Message, ex.StackTrace, ex.InnerException);

            }

return true;

 

 

Show all comments