Use Calculated Value to set field of type Hyperlink/Picture, using foreign list with lookup
AnsweredI wish to populate a Hyperlink/Picture field in a Document Library (as metadata column to Document Set Content Type), based on a user's selection in a Lookup field to a SharePoint List that contains text values and corresponding picture URLs (also in a Hyperlink/Picture field).
I have a SharePoint (online) Document Library, with Content Types enabled.
In that Document Library, I have a Document Set Content Type, with additional relevant columns added:-
- ThisStatus (lookup to StatusImages:Status)
- ThisStatusImage (Hyperlink/Picture) (I want to set this field using skybow solution studio Calculated Values)
I have a separate SharePoint list 'StatusImages' with relevant columns:-
- Status (Text field - example values : 01 Red, 02 Amber, 03 Green etc.)
- StatusImage (Hyperlink/Picture contains URL to image that corresponds to the text in the Status field)
Note : SharePoint (O365) does not permit Hyperlink/picture fields to be selected as 'Additional Lookup Fields'; if it did I would simply use that.
I therefore need to populate the Document Set item's ThisStatusImage field with the corresponding StatusImage (URL) from the StatusImages List, based on the lookup value chosen for ThisStatus for the Document Set.
I expected I should be able to achieve this using skybow solution studio's Calculated Values, however I cannot make it work.
My latest attempt was:-
(Function Code Expression)
[[@Web.GetFirstValueForQuery('StatusImages', '<Query><Where><Eq><FieldRef Name=ID /><Value Type=Counter>'+[[ThisStatus.Key]]+'</Value></Eq></Where></Query>', 'StatusImage')]];
However, using the Test button in the Expression Builder, this returns "null". The List (Document Library) item selected for the Test does contain a valid value for ThisStatus (i.e. looked-up to StatusImages:Status).
I also tried the above without wrapping in <Query></Query>, and got the same "null" result.
Another attempt (I can't remember the exact code/configuration) returned:
Microsoft.SharePoint.Client.FieldUrlValue
Which I suspect is closer to what I need, as I've found javascript through Google search that suggests I need to apply get_url() to this, however I couldn't work out how to do that in solution studio.
Can anyone please offer any assistance to help me achieve this need?
-
Hi John471
You're quite close to the right solution. I built the same structure/configuration and found the following .Url property request is the only missing part:
[[@Web.GetFirstValueForQuery('StatusImages', '<Where><Eq><FieldRef Name=ID /><Value Type=Counter>[[ThisStatus.Key]]</Value></Eq></Where>', 'StatusImage')]].Url
0
Please sign in to leave a comment.
Comments
1 comment