locked
How to get displayname of lightswitch entities by the query in HTML client RRS feed

  • Question

  • when I do a query, the lightswitch server returns a collection of entities its has found, but I can only Get the property name of the entities, and now I want get a collection that contains the entities's displayname. how to do this?tkx
    Tuesday, November 4, 2014 1:46 PM

Answers

  • Chopic,

    I don't think you can do that 

    dataArr[displayname1] = value1;

    because the 'name' property of an entity is unique, but its 'displayName' is not. You can have different properties with the same displayName and different names. The name is the identifier.


    Nicolás Lope de Barrios
    If you found this post helpful, please "Vote as Helpful". If it actually answered your question, please remember to "Mark as Answer". This will help other people find answers to their problems more quickly.

    Wednesday, November 5, 2014 11:56 AM

All replies

  • Queries always return the entire entity, because of the Entity Framework. Can you post the code you are using, so we can give better advice?

    Just in case, if you are querying objects of type IEntityObject, you can access their Description, DisplayName, and other properties, via Details, for example if your object's name is entity:

    String displayName = entity.Details.DisplayName


    Nicolás Lope de Barrios
    If you found this post helpful, please "Vote as Helpful". If it actually answered your question, please remember to "Mark as Answer". This will help other people find answers to their problems more quickly.

    Tuesday, November 4, 2014 9:43 PM
  • thanks very much for you reply.but I still don not know how to get the displayname property in the html client.

    I have browse the object "screen.ExportQuery" the get from the server but I can not find the displayname property in chrome borowser 

    Wednesday, November 5, 2014 2:20 AM
  • Chopic,

    It's unclear what you're trying to achieve. Please post a screenshot of the entity you want to get the DisplayName for, and the code you wrote, so we can understand what you're saying. For example, now we know you meant in the HTML client, when I assumed you were talking about server side.


    Nicolás Lope de Barrios
    If you found this post helpful, please "Vote as Helpful". If it actually answered your question, please remember to "Mark as Answer". This will help other people find answers to their problems more quickly.

    Wednesday, November 5, 2014 3:48 AM
  • tks very much,but it's woeful that I can not upload screenshot in reply. so I post my code instead. Anyhow thx all the same.

    //store the queried data in dataArr,
    //entities is the query result from the server
    function PushData(entities, dataArr) {
        for (var i = 0; i < entities.count; i++) {
            var myItem = entities.data[i];
            var value = {};
    
            for (x in myItem) {
                switch (typeof (myItem[x])) {
                    case "boolean":
                        {
                           //when I store my data,'x' is the property name rather than displayname
                            value[x] = ConvertBoolen(myItem[x]);//ConvertBoolen function converts boolean value into Yes or No.
                            break;
                        }
                    case "function":
                        {
                            continue;
                            break;
                        }
                    default:
                        {
                            value[x] = myItem[x];
                            break;
                        }
                }
            }
    

    eg. enterprise:{property1 displayname1},{property2 displayname2}…

    now I want organize my 'dataArr' like the format:

    dataArr[displayname1] = value1;

    dataArr[displayname2] = value2;

    in the html client . how can I get the entities' [diaplayname] property in the query result?

    Wednesday, November 5, 2014 7:45 AM
  • Chopic,

    I don't think you can do that 

    dataArr[displayname1] = value1;

    because the 'name' property of an entity is unique, but its 'displayName' is not. You can have different properties with the same displayName and different names. The name is the identifier.


    Nicolás Lope de Barrios
    If you found this post helpful, please "Vote as Helpful". If it actually answered your question, please remember to "Mark as Answer". This will help other people find answers to their problems more quickly.

    Wednesday, November 5, 2014 11:56 AM
  • For the record, to convert boolean to yes or no, you can create a Choice List in the Entity Designer, selecting True as value, Yes as display value, etc.


    Nicolás Lope de Barrios
    If you found this post helpful, please "Vote as Helpful". If it actually answered your question, please remember to "Mark as Answer". This will help other people find answers to their problems more quickly.

    Thursday, November 6, 2014 3:24 PM
  • Chopic,

    The displayName of an entity property is not included in the model.json so I don't believe it's accessible in HTML Client javascript.  displayName of a contentItem on a screen is in the model, but not displayName of a table field.

    HTH,

    Josh

    Saturday, November 8, 2014 12:34 AM
  • Thanks for your reply. Sorry for my late response.I will try your suggestion about the way to convert boolean to yes or no.I think I have to find another way to deal with the displayname.

    thanks a lot !!!

    Saturday, November 8, 2014 1:37 AM