Skip to main content

Search

add sublist item from command bar action

Comments

5 comments

  • Christof

    Yes, you can use the Add List Item Action on Command Bar buttons to add a sublist item.

    Just use the [[ID]] of current item (main item) as lookup reference to set the relation to main item.

    This Action is available as well on List Actions (Command Action) buttons which are rendered in the Command Bar on List Views which can be executed in context of selected item(s):

    0
  • Ruba Abu Alrob

    Hi 

     

    Thank you for your solution. Definitely it solved part of the task. 

    After creating the Sublist item, I need the action of opening the edit form of that sublist item. but how can I get the ID of the  created item. 

    Thanks

    0
  • Christof

    There is an Expression to achieve this: https://my.skybow.com/hc/en-us/articles/360012039240-How-to-get-the-latest-item-created-by-me-using-expression-functions 

    This returns the ID of the last created item in the defined list - which is the item created with the Add List Item action before.

    0
  • Ruba Abu Alrob

    Thank you for the promote reply. 

     

    Can I get a lookup attribute using the CAML Query? 

    [[@Web.GetFirstValueForQuery('Project', '<Where><Eq><FieldRef Name=Author LookupId=True  /><Value Type=User ><UserID/></Value></Eq></Where><OrderBy><FieldRef Name=Created Ascending=False /></OrderBy>', 'ID')]]

     

    instead of ID, to be a lookup field id

    for Example: 

    [[@Web.GetFirstValueForQuery('Project', '<Where><Eq><FieldRef Name=Author LookupId=True  /><Value Type=User ><UserID/></Value></Eq></Where><OrderBy><FieldRef Name=Created Ascending=False /></OrderBy>', 'Lookupfield.id')]]

     

    Thank you

    0
  • Christof

    Yes, if you define the lookup field as result field you'll get back the lookup's value as an SP.FieldLookupValue object with functions to get lookup's id and value.

    [[@Web.GetFirstValueForQuery('ListName or relative Url', 'Caml query', 'YourLookupFieldName')]].get_lookupId()

     

    Checked this by logging the result of the query function into browsers console and investigate the object there - very technical but probably interesting :)

    console.log([[@Web.GetFirstValueForQuery('Activities', '<Where><Eq><FieldRef Name=Author LookupId=True /><Value Type=User ><UserID/></Value></Eq></Where><OrderBy><FieldRef Name=Created Ascending=False /></OrderBy>', 'LookupToExpenses')]]);
    return [[@Web.GetFirstValueForQuery('Activities', '<Where><Eq><FieldRef Name=Author LookupId=True /><Value Type=User ><UserID/></Value></Eq></Where><OrderBy><FieldRef Name=Created Ascending=False /></OrderBy>', 'LookupToExpenses')]].get_lookupId();
    0

Please sign in to leave a comment.