Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Unanswered

CRM Custom workflow - An unexpected error occurred

(0) ShareShare
ReportReport
Posted on by 1,703

CRM2016 On premises

I have created a plugin to drag in records from a SQL server, however I am getting an unexpected error occurred.

I'm at a total loss as to how to track down what is causing this error.

Does CRM have any workflow logs when looking in the workflow Process sessions there are no records.

Dim NewTransaction As New Entity("new_transactions")

                    Dim rtn_TransactionValue As Decimal = SQLReader.GetDecimal(TransValue)

                    NewTransaction("new_transactionsetid") = context.PrimaryEntityId

                    NewTransaction("new_createdon") = CDate(SQLReader.GetValue(CreatedDate))

                    NewTransaction("new_createdby") = CreatedByID

                    NewTransaction("new_sortcode") = SQLReader.GetString(DestSortCode)

                    NewTransaction("new_accountnumber") = SQLReader.GetString(DestAccountNumber)

                    NewTransaction("new_daccountname") = SQLReader.GetString(DestAccountName)

                    NewTransaction("new_reference") = SQLReader.GetString(DestBankRef)

                    NewTransaction("new_value") = rtn_TransactionValue

                    NewTransaction.Attributes.Add("new_transactioncode", New OptionSetValue(SQLReader.GetValue(TransCode)))

                    NewTransaction.Attributes.Add("new_transactiontype", New OptionSetValue(SQLReader.GetValue(TransType)))

                    NewTransaction("new_rti") = SQLReader.GetString(RTICode)

                    service.Create(NewTransaction)

  • Pete_N Profile Picture
    1,703 on at
    RE: CRM Custom workflow - An unexpected error occurred

    Update,  I have tracked the error down

    The entity that is calling the workflow is new_transactionsets. The workflow creates a record in new_transactions

    new_transactionsets has a 1 : N relationship to new_transactions ( field in new transactions  new_transactionsetid )

    NewTransaction("new_transactionsetid") = context.PrimaryEntityId is the line that is causing the issue and I am getting an error ,

      <Message>There is no active transaction. This error is usually caused by custom plug-ins that ignore errors from service calls and continue processing.</Message>

    If I manually create a record in new_transactions and then look at the raw SQL table, I can see that the value in new_transactionsetid is the same as context.PrimaryEntityId

    Currently I am running the workflow as an On-Demand

    Help

  • Pete_N Profile Picture
    1,703 on at
    RE: CRM Custom workflow - An unexpected error occurred

    sorry should have said workflow not plugin

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Daivat Vartak (v-9davar) Profile Picture

Daivat Vartak (v-9d... 225 Super User 2025 Season 1

#2
Eugen Podkorytov Profile Picture

Eugen Podkorytov 106

#2
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 106 Most Valuable Professional

Overall leaderboard

Product updates

Dynamics 365 release plans