Question

Photo of Richard Sanford

0

Select from a list of returned values from a dataview...

In workflow I'm trying to create an attribute that I can display on an entry form. I have an existing dataview that provides me with certain selected Location values. I want to know if there is a way I can reference the dataview to provide results that the user can perform a single select when the entry form is opened. I can do this with defined values but then I'm keeping the same Location type info in 2 places. Any ideas?


thanks...

  • Photo of Michael Garrison

    0

    If you have Lava Entity commands enabled globally, you can use something like this to populate your single-select:

    {% location dataview:'8' %}{% for l in locationItems %}{{ l.Name }}^{{ l.Guid }},{% endfor %}{% endlocation %}

    (replace 8 with the Id of your dataview)

    From there, you should be able to refer to the RawValue of this single select attribute to get the GUID of the selected location (which should in turn be the value you need to write to a location type attribute to have it populate as you'd expect

    Let us know how that works!

  • Photo of Richard Sanford

    0

    here's what I tried ... I pasted the lava code into the Values  for the Single Select field type for the attribute and when the form opened I got a list of GUIDs...

    Capture1.PNG

    Capture2.PNG



  • Photo of Richard Sanford

    0

    hey Michael I got it...I just removed '^{{ l.Guid }}' from the lava code and it showed my location name values in the single select dropdown just like I wanted...this is great because I will be using this little code snippet in several places...thanks so much...

  • Photo of Michael Garrison

    0

    Quite right, I had the values backwards. It should have been

    {% location dataview:'8' %}{% for l in locationItems %}{{ l.Guid }}^{{ l.Name }},{% endfor %}{% endlocation %}

    I do recommend doing it this way, so that you can use RawValue to populate a Location type attribute if you need it. But I'm glad you got it working for the time being :)

  • Photo of Richard Sanford

    0

    Hey Michael do you know if there's a way to dynamically supply the dataview ID based on the value of another attribute in the workflow ie. if I have an attribute A1 from another single select could I do like a CASE statement checking the id value of A1 and then setting the dataview ID value to something specific?

  • Photo of Michael Garrison

    0

    There's not a way to do that unfortunately; attribute options have to be able to be calculated when you save the workflow as well as when it runs; your attribute doesn't "exist" yet when you're saving the workflow definition. So you can't have attributes whose options are dependent upon other attributes...only attributes whose _value_ is set dynamically.

  • Photo of Richard Sanford

    0

    Hi Michael, I'm trying to take the single select dataview item another step forward...I'm making my own version of the basic Facility Request workflow and what I want to do is to change the attribute NewWorker from person type to single select with values coming from a dataview I've setup, similar to how the locations are working off a dataview...so my Person DV is just checking Person type to see if a person field attribute value is = yes and it displays Nick Name, Last Name, Gender and Email, no GUID...is that normal? ...so I would like to use the same lava code you gave me yesterday and i made a changed version that doesn't work..

    {% location dataview:'8' %}{% for l in locationItems %}{{ l.Guid }}^{{ l.Name }},{% endfor %}{% endlocation %} changed to

    {% person dataview:'24' %}{% for l in personItems %}{{ l.Nick Name }}^{{ l. Last Name }},{% endfor %}{% endperson %}

    I thought this would work but the workflow won't save it...am I going down the wrong road again LOL??


  • Photo of Michael Garrison

    0

    1) Yes, it's normal for DataViews to not show a GUID field.
    2) Person attributes are "stored" using PrimaryAliasGuid, so I would use this instead:

    {% person dataview:'24' %}{% for p in personItems %}{{ p.PrimaryAlias.Guid }}^{{ p.NickName }} {{ p.LastName }},{% endfor %}{% endperson %}

    Let us know if this doesn't work for you; I may be misunderstanding what you're doing/asking

  • Photo of Richard Sanford

    0

    YES!  that worked perfectly...