0

I have two lists. All our vehicles are included in a list (cars list). The other list (cars review list) shows which vehicle was inspected and when. When I click on a vehicle in the "cars list" I come to the detailed view of the vehicle. On this view I would like to have a button with which I can enter a new inspection of the vehicle in the list "cars review list".

But now I would like to have preselected the vehicle in the new form. How do I get the connection?

  • I am sorry, I do not follow what you are trying to do. Can you please elaborate, and present your problem a bit clearer? – lazoDev Sep 10 at 11:21
  • as LazoDev pointed out please provide some screenshot to understand your query. – vinit kumar Sep 10 at 11:23
  • Now is it a little bit more understandable? – cvb Sep 10 at 13:34
0

This can be done fairly easily with some Javascript.

You'll have to embed some Javascript on the Display form of the cars list that will add the button, and handle the button click. When someone clicks the button, I would open the New form of the "cars review" list in a modal dialog because you can pass arguments to the dialog as part of the options in SP.UI.ModalDialog.showModalDialog(options), so at that point you can pass the ID of the car item you are looking at the detail of, and use that in the New form of the review list to pre-select the car.

Keep in mind that you will also have to embed some Javascript on the New form of the car review list that will check to see if modal dialog args have been passed, and if so, then use that to pre-select the car, or if no args have been passed, do nothing (because maybe the form wasn't opened from the special button on the Display form of the cars list, maybe it was just opened normally, so you can't assume that the ID of a specific car was passed, and need to be able to gracefully handle both possibilities).

You can find lots of examples of how to embed scripts on SharePoint forms/pages and how to use SP.UI.ModalDialog out there on the internet. The trickiest part might be figuring out how to read the args passed to the modal. The easiest solution I've found is to check for window.frameElement.dialogArgs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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