Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

What Destination Name to use with DataServiceTransaction in Model Driven approach

Avatar

Former Community Member

Hello

I am using Model Driven Approach where no destinations are configured in data-management-config.xml, it is done automatically. In my backend webapp, I want to persist some data and push the changes to the clients. While I can use DataServiceTransaction.createItem() but what destination name should I use? What is the default name of the destination created by model assembler?

thanks

RK

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

As Don mentioned in the other thread, you can use the ServerGeneratedEntities annotation to control this. For more information, see this documentation:

http://help.adobe.com/en_US/LiveCycleDataServicesES/3.1/Developing/WS4976f0ec3ef482461096f3811270185...

View solution in original post

5 Replies

Avatar

Employee

Hi Rupak,

You should pass the destination name to DST. And by default, it is called <ModelName>.<NameOfEntity>

Rohit

Avatar

Former Community Member

The Destination Id is <ModelName>.<EntityName> (Note the dot . in between the two parts). If you have Flash Builder with the Data Services Modeller plugin installed, you can actually see the destination in the Destinations view, under DMS Destinations.

I also wanted to note, if you run into issues calling Data Service Transaction on the server, you may want to try setting the Message Broker on the FlexContext like this:

MessageBroker messageBroker = MessageBroker.getMessageBroker(null); //Pass in the Message Broker ID if you have changed it.
FlexContext.setThreadLocalMessageBroker(messageBroker);

then when you are done with the Data Service Transaction, you can call setThreadLocalMessageBroker() with null.

Avatar

Former Community Member

Hi Ashish

Now the Destination ID is correct but I get the following exception. Also tried setting the Message Broker on the FlexContext but same error. The code is as follows.

Pls advise

Rupak

        MessageBroker messageBroker = MessageBroker.getMessageBroker(null); //Pass in the Message Broker ID if you have changed it.
        FlexContext.setThreadLocalMessageBroker(messageBroker);

         DataServiceTransaction dtx = DataServiceTransaction.begin(false); 
         //DataServiceTransaction dtx = DataServiceTransaction.getCurrentDataServiceTransaction();
         dtx.setSendChangesToAdapter(true);
         Currency c1 = new Currency();
         c1.setCurrencyCode("ABC");
         c1.setCurrencyName("Dummy Currency");
         c1.setCurrencyLastUpdated(new Date());
         c1.setCurrencyId(new Integer(537)); 
         dtx.createItem("TraderWorkStation.Currency", c1); 
         dtx.commit();
        
         FlexContext.setThreadLocalMessageBroker(null);

TWSServer08/24/2011 11:15:31.736 DEBUG Service.Data.Transaction Started non-jta data service transaction

TWSServer08/24/2011 11:15:31.768 DEBUG Service.Data.Transaction Sending server message to adapter: Flex Message (flex.data.messages.DataMessage)

    operation = create

    id = {currencyId=537}

    clientId = srv:91D4E7AE-B0DB-B0EA-681D-4404F4AC8E96

    correlationId = null

    destination = TraderWorkStation.Currency

    messageId = srv:91D4E7AE-B0DB-B0EA-681D-4404F4AC8E96:0

    timestamp = 1314198931739

    timeToLive = 0

    body = TraderWorkStation.Currency@238

TWSServer08/24/2011 11:15:31.771 DEBUG Service.Data.General Before TraderWorkStation.Currency.createItem (

    (TraderWorkStation.Currency) {currencyId=537} (14308998) {

        currencyName = Dummy Currency

        currencyCode = ABC

        currencyId = 537

        currencyLastUpdated = Wed Aug 24 11:15:31 EDT 2011

    })

TWSServer08/24/2011 11:15:31.797 DEBUG Endpoint.AMF Serializing AMF/HTTP response

Version: 3

  (Message #0 targetURI=/1/onStatus, responseURI=)

    (Typed Object #0 'flex.messaging.messages.ErrorMessage')

      headers = (Object #1)

      rootCause = null

      body = null

      correlationId = "7816F4B3-E6EC-B7CD-A98D-FC5EFF8A3646"

      faultDetail = null

      faultString = "The item of type, 'TraderWorkStation.Currency', passed to the assembler does not match the assembler's configured entity type, 'TraderWorkStation.package1.Currency'.  To convert 'flex.messaging.io.amf.ASObject' to a strong type automatically, set the item-class in the destination."

      clientId = "91D4E4EF-9095-35C3-0E30-0059517696E5"

      timeToLive = 0.0

      destination = "AdminControlService"

      timestamp = 1.314198931792E12

      extendedData = null

      faultCode = "Server.Processing"

      messageId = "91D4EF9D-F0F1-D3D1-5F9B-2F636C098859"

Message was edited by: RupakKhurana

Avatar

Correct answer by
Former Community Member

As Don mentioned in the other thread, you can use the ServerGeneratedEntities annotation to control this. For more information, see this documentation:

http://help.adobe.com/en_US/LiveCycleDataServicesES/3.1/Developing/WS4976f0ec3ef482461096f3811270185...

Avatar

Former Community Member

Ok, so far so good, but in my original code, I am using dtx.setSendChangesToAdapter(true) and expect that the createIte

m() would be persisted to the database. Is it not the case, while I see that the new item is sent to the client but it is not being written to the database.

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----