0

I have a custom list with a column that has a look-up field. I want to populate dynamically some values from another list to a column of the current list on the basis of what is chosen in the look-up field.

For example if i choose "F.Sc Pre Eng. Part 01" in Program Name the related courses should be displayed dynamically in Course column. Student List Example

Note: Currenltly i'm using Set field action in my workflow. But it set value after the list item is created and i want run time dynamic values in Course column.

SPD 2013 workflow

Thanks!

4
  • Why don't you just select Courses as an additional column in the lookup for Program Name? May 12, 2018 at 14:30
  • You can't use workflow to solve this problem as it always triggers after the record is saved. It will have to be JavaScript on a SharePoint page I think.
    – unibod50
    May 12, 2018 at 18:21
  • @PerJakobsen because the values that i want to save in course column are already look-up from another list May 13, 2018 at 16:57
  • @unibod50 infopath has a way to do this but i'm looking for a method in SPD. May 13, 2018 at 16:59

1 Answer 1

1

From your description, since the workflow action cannot dynamically populate the field based on the selection of look up field, I recommend you using code with SPServices in the Newform.aspx and Editform.aspx page in SharePoint Designer. Edit the form page in advanced mode and add the script below: In my test,

Current List: list5, Columns: Project Name, Course.

Information list: list4, Columns:ProjectName, course.

Please change the relevant column name and list name for your list.

<script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/2014.02/jquery.SPServices-2014.02.min.js"></script>

<script type="text/javascript">
$(document).ready(function() {
var ID;
$('select[title="Project Name"]').change(function(){
ID =  $('select[title="Project Name"] option:selected').val();
  $().SPServices({
    operation: "GetListItems",
    async: false,
    listName: "list4",
    CAMLViewFields: "<ViewFields><FieldRef Name='course' /></ViewFields>",
    CAMLQuery:  "<Query><Where><Eq><FieldRef Name='ID'/><Value Type='Counter'>" + ID + "</Value></Eq></Where></Query>",
    completefunc: function (xData, Status) {
      $(xData.responseXML).SPFilterNode("z:row").each(function() {
        var course = $(this).attr("ows_course");
            $('input[title="Course"]').val(course);
          });
        }

  });
  });
});
</script>

enter image description here

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.