want to auto-populate catalog item from a widget

Mike Stockman1
Giga Guru

I have a widget on my user_profile page that brings up a catalog item to allow update account profile info.

profile 1.png

This catalog item currently has default value on User (u_user) set to javascript:gs.getUserID().

profile 2.png

That works great unless Im wanting to update another person from their profile page.

profile 3.png

So the question is - how do i get my catalog item 'Update Account Profile' to load the value of the user being checked?

Is this something i have to change the catalog item's widget or is there a way i can call from a onLoad script inside my catalog item ?

I'd like my logic to be if i'm on a user_profile page, load the catalog item with that user's info, if not, then load my info (logged in user)

1 ACCEPTED SOLUTION

larstange
Mega Sage

Hi



A "pure" catalog item will not be able to do this. The only way to do it, is to add a parameter to the page URL when opening the catalog item. But the client scripts in the catalog item will not be able to access the URL to get that parameter.


So what you can do is add a SP Widget to the catalog item, which can access the URL parameter and update your User variable.


  1. You add the SP Widget in a "Macro" variable - It can be visually invisible.
  2. You fetch the parameter using $sp.getParameter('paramter_name')
  3. You can update the Catalog Item User variable from the Widget using $scope.page.g_form.setValue("UserVarName","UserSysIDfromParameter");


The alternative would be to build a pure widget solution and not use a catalog item at all.


View solution in original post

4 REPLIES 4

larstange
Mega Sage

Hi



A "pure" catalog item will not be able to do this. The only way to do it, is to add a parameter to the page URL when opening the catalog item. But the client scripts in the catalog item will not be able to access the URL to get that parameter.


So what you can do is add a SP Widget to the catalog item, which can access the URL parameter and update your User variable.


  1. You add the SP Widget in a "Macro" variable - It can be visually invisible.
  2. You fetch the parameter using $sp.getParameter('paramter_name')
  3. You can update the Catalog Item User variable from the Widget using $scope.page.g_form.setValue("UserVarName","UserSysIDfromParameter");


The alternative would be to build a pure widget solution and not use a catalog item at all.


Thank you I will give that a try today and post 'Correct Answer' when it's done  


questions:


on line 2 you mention fetch the parameter. If i understand what you're saying, in my widget, the call would be in my client script of the widget?



then in line 3 above - updating the user variable from the widget   - would also be done in that client script of the widget?



so on my catalog item, i only need to add the new macro variable that references the SP widget I modified?


larstange
Mega Sage

Hi



Normally $sp.getParameter('paramter_name') is called from the Server part - I'm not sure it will work in the client side part.



But as long as you set the parameter to the data object to will be passed to the client side automatically, so its not a big issue



data.parameter = $sp.getParameter('paramter_name');



And it the client part you can access it via "c.data.parameter"