moqui/moqui-framework

In entity-auto update service for entity [moqui.basic.email.EmailMessage] value not found, cannot update; using parameters [[bodyText:, statusId:ES_READY, body:...

Closed this issue · 2 comments

This error occurred in sendEmailTemplate.groovy, and the key code is as follows:

    if (createEmailMessage) {
        Map cemParms = [statusId:"ES_DRAFT", subject:subject,
                        fromAddress:fromAddress, fromName:fromName, toAddresses:toAddresses, ccAddresses:ccAddresses, bccAddresses:bccAddresses,
                        contentType:"text/html", emailTypeEnumId:emailTypeEnumId,
                        emailTemplateId:emailTemplateId, emailServerId:emailTemplate.emailServerId,
                        fromUserId:(fromUserId ?: ec.user?.userId), toUserId:toUserId]
        Map cemResults = ec.service.sync().name("create", "moqui.basic.email.EmailMessage").requireNewTransaction(true)
                .parameters(cemParms).disableAuthz().call()
        emailMessageId = cemResults.emailMessageId
    }

    // prepare the html message
    def bodyRender = ec.screen.makeRender().rootScreen((String) emailTemplate.bodyScreenLocation)
            .webappName(webappName).renderMode("html")
    String bodyHtml = bodyRender.render()

    // prepare the alternative plain text message
    // render screen with renderMode=text for this
    def bodyTextRender = ec.screen.makeRender().rootScreen((String) emailTemplate.bodyScreenLocation)
            .webappName(webappName).renderMode("text")
    String bodyText = bodyTextRender.render()

    if (emailMessageId) {
        ec.service.sync().name("update", "moqui.basic.email.EmailMessage").requireNewTransaction(true)
                .parameters([emailMessageId:emailMessageId, statusId:"ES_READY", body:bodyHtml, bodyText:bodyText])
                .disableAuthz().call()
    }

The email message added above was not found below. The reason for this error seems to be due to 'requireNewTransaction (true)'?

eigood commented

What exception did you get? What other code was called before this? What series of steps brought you to this place in the code? This issue needs to have enough repeatable steps to figure out the problem.

We have investigated and resolved this issue. It is not a bug in Moqui, but rather a result of the separation of writing and reading in our database, resulting in a short period of time when data is not synchronized between read and write databases.
This issue is a false alarm, sorry.