More in this section

Forums / General Discussions / Module Creating/Retrieve dynamic field Value

Module Creating/Retrieve dynamic field Value

13 posts, 1 answered
  1. Jmr
    Jmr avatar
    53 posts
    Registered:
    21 Jan 2011
    21 Jan 2011
    Link to this post
    Hi,

    I have already created Dynamic Data field with values like or used below API 

    sf.Documents().GetManager().Provider.SuppressSecurityChecks = true;
                    sf.Document().CreateNew().Do(item =>
                    {
                        item.Parent = sf.DocumentLibraries().Where(l => l.Title == ModuleName).Get().FirstOrDefault();
                        item.Title = title;                    
                        item.UrlName = title + "_Application";
                        item.SetValue("id", id);
                        item.SetValue("FullName", "SitefinityCMS");
                    }).Publish();

    and i want to retrieve the FullName Column value i.e SitefinityCMS using API.
    Please let me know how to get those values as soon as possible.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    21 Jan 2011
    Link to this post
    Hi Mohammad,

    There is DataExtension method GetValue that you can use to get the value of your custom field.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Jmr
    Jmr avatar
    53 posts
    Registered:
    21 Jan 2011
    21 Jan 2011
    Link to this post
    Hi 
    Thanks for valuable reply.

    Please explain me little more with syntax then i can understand well.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    21 Jan 2011
    Link to this post
    Hello ,

    Here is a sample

    var manager = LibrariesManager.GetManager();
    var id = new Guid("6e8230d5-9ba6-43ed-9aaa-4fc7de1c76c3");
    var item = manager.GetItem(typeof(Image), id) as Image;
    var value = item.GetValue("FullName");


    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
    Answered
  5. Jmr
    Jmr avatar
    53 posts
    Registered:
    21 Jan 2011
    21 Jan 2011
    Link to this post
    Hi

    If i try that code i am getting the following error.

    var item = manager.GetItem(typeof(Image), id) as Image; this line gives 
    You are trying to access item that no longer exists. The most probable reason is that it has been deleted by another user.

    Please solve my problem
    Thanks
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    21 Jan 2011
    Link to this post
    Hello Mohammad,

    Most probably you are not passing an valid ID of the item.

    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Jmr
    Jmr avatar
    53 posts
    Registered:
    21 Jan 2011
    21 Jan 2011
    Link to this post
    HI
    Thanks for your express reply.
    I got the solution

     
  8. Jmr
    Jmr avatar
    53 posts
    Registered:
    21 Jan 2011
    03 Feb 2011
    Link to this post
    Hi

    I can get value dcs.GetValue("ID").Equals("IDvalue")

    is it possible to do 

    dcs.GetValue("Date").  =< (Equals or Greater then) ("DateValue")


  9. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    13 Feb 2011
    Link to this post
    Hello Jmr,

    GetValue returns an object and this is why you can use Contains directly. To make comparison by other parameters you need to cast the object ( for instance to string) and then use proper expressions.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  10. UI Crew
    UI Crew avatar
    99 posts
    Registered:
    24 Sep 2012
    07 Apr 2011
    Link to this post
    Hi,

    If you have a ContentItem how to you retrieve a dynamicfield for it?

    Cheers,

    Seth
  11. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    07 Apr 2011
    Link to this post
    Hello ,

    There is extension method GetValue("yourfield") of the content item .You should have reference to DataTelerik.Sitefinity.Model.

    Regards,
    Ivan Dimitrov
    the Telerik team

  12. Vivid Group
    Vivid Group avatar
    8 posts
    Registered:
    01 Dec 2009
    11 May 2011
    Link to this post
    Hi Ivan,

    I tried to use:

    var manager = LibrariesManager.GetManager();
    var id = new Guid("6e8230d5-9ba6-43ed-9aaa-4fc7de1c76c3");
    var item = manager.GetItem(typeof(Image), id) as Image;
    var value = item.GetValue("FullName");


    However I can't find the GetValue method in the Image.
    Also tried this:
    DataExtensions.GetValue(item, "FieldName");

    And it doesn't like the fact that item is not type of IDynamicFieldsContainer.

    Can you please advise?

    Thanks,
    Evan 
  13. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    13 May 2011
    Link to this post
    Hello ,

    Have you added using Telerik.Sitefinity.Model;

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
13 posts, 1 answered