Forum Discussion

peterlu's avatar
peterlu
Champion
12 years ago

custom user setting problem / issue

<#if !user.anonymous>

profile.user.data = ${settings.name.get("profile.user.data")}

<@liaAddScript>
;(function($) {
	$.post("/restapi/vc/users/self/profiles/name/user.data/set", {value: "my user data Two"}).done(function(data) {
		console.log(data);
		alert("done");
	}).fail(function() {
		alert("error");
	});
})(LITHIUM.jQuery);
</@liaAddScript>

</#if>

 

This code prints out

profile.user.data = my user data ONE

and when I tried to set it to "my user data Two", I got "error code 100 - An unexpected error has occured" in the response. I was logged in as admin, and I was testing it inside studio component editor.

 

I have also tried all these:

$.post("/restapi/vc/users/self/profiles/name/user.data/set", ...

$.post("/restapi/vc/users/self/profiles/name/profile.user.data/set", ...

$.post("/restapi/vc/users/self/settings/name/user.data/set", ...

$.post("/restapi/vc/users/self/settings/name/profile.user.data/set", ...

Also no luck.

 

BTW, lithium team helped us set up this:

[profile]

user.data    :wcu   string  0   64000

 

Thanks.

7 Replies

  • JasonL's avatar
    JasonL
    Lithium Alumni (Retired)
    12 years ago

    Hi Peter,

    could it be the &colon?

     

    data &colon;  {			
    						value:"newuserdata"
    					},

     

  • peterlu's avatar
    peterlu
    Champion
    12 years ago

    no, &colon; is just the copy and paste error by wysiwyg.

     

    BTW, i have updated the original post.

  • peterlu's avatar
    peterlu
    Champion
    12 years ago

    is there any TKB article or guidde on how to set and retrieve custom settings?

  • JasonL's avatar
    JasonL
    Lithium Alumni (Retired)
    12 years ago

    peterlu wrote:

    is there any TKB article or guidde on how to set and retrieve custom settings?


    Hi Peter,

    Usually these settings are done by our PS team as you'll need access to the backend to change.

     

    so I'm afraid we don't have any external docs (not that I'm aware of).

     

    The closest i've seen is probably this:

    https://lithosphere.lithium.com/t5/developers-knowledge-base/Context-objects-for-custom-components-settings/ta-p/9335

     

    Back to your original question, you should try to drop the custom component into page and verify from that page - instead of within studio

    (when i tried to drop into a page - albeit modify to match the custom settings i have - it worked fine with admin acct - saw the alert window and console log)

  • peterlu's avatar
    peterlu
    Champion
    12 years ago

    Thanks, Jason. Lets start over.

    Just to confirm that we are using the right custom settings as there was some changes made after the initial request. user.data was changed to profile. (hinterlands.demo)

     

    According to what we are aware, these are the settings that have been set up.

     
    [hinterlands]    
    data                                     :wc        string      0       64000
    [profile]
    user.data                             :wcu      string      0       64000
     
    What is the difference between [hinterlands] and [profile]?
     
    Given this is correct, we are able to print these settings out. We have set values previously as you can see below.
    [logged in as hinterlands] (admin)
    <response status="success">
    <value type="string">my user data</value>
    </response>

     http://hinterlands.demo.lithium.com/restapi/vc/users/self/settings/name/profile.user.data

    <response status="success">
    <value type="string">my user data ONE</value>
    </response>

     

     
    The problem we are having is that we can no longer set these settings by using the code supplied in the original post.
    Does this code work for you on your system?
    btw, we have tried them in a custom component and tested them in a page.
    It is critical for us to set these settings.
     
     
  • JasonL's avatar
    JasonL
    Lithium Alumni (Retired)
    12 years ago

    Hi Peter,

    I honestly got no clue what's your use cases are nor what intentions were :smileyhappy:

    Guessing  [profile] user.data is probably what you should be using.

     

    I took a quick look at your env and i think i understand what's happening.

     

    The profile settings were added to your env in revision 588289 (at least from the back-end I see)

    when you revert to revision 453056 - the file that contains the profile setting gets deleted

     

    Try reverting back to the 588289 revision, that should do the trick

  • peterlu's avatar
    peterlu
    Champion
    12 years ago

    Thank you, Jason, it works now for admin.
    ---------------------------------------------------------
    profile.user.data = ${settings.name.get("profile.user.data")}
    ----------------------------------------------------------
    /restapi/vc/users/self/settings/name/profile.user.data/set

     

     

    But not for the normal user. Now i get error 303. Permission Denied.