add sublist item from command bar action
Hi,
I have a parent list, and a sub-list.
It is required to add item for sub-list from an action in command bar, not the default command bar of the sub-list.
is there anyway to do that?
-
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 -
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 -
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 -
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 -
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.
Comments
5 comments