Create Group With Extended attribute through Widget API

Create Group With Extended attribute through Widget API

This question is answered

Hi

I am using Telligent Community Server 6.1.0.23780 and need to create a group with multiple extended attributes from the custom widget that I have created in the Widget studio.

Following is the script that I have written to add a group in the system:

#if ($core_v2_page.IsPost)

   $core_v2_page.SetContentType('application/json')

            #set($groupName = '')

#set($groupName = $core_v2_page.GetFormValue('groupName'))

#set($groupType = '')

#set($groupType = $core_v2_page.GetFormValue('groupType'))

   #set($ExtendedAttributes = "{SampleConf=TestValue}")

   #set($groupResponse = $core_v2_group.Create($groupName, $groupType, "%{ExtendedAttributes = $ExtendedAttributes}"))

   #if ($groupResponse && $groupResponse.Errors.Count == 0)

       {"success":"True","message":"Success...$groupName $groupType " }

   #else

       $core_v2_page.SendJsonError($groupResponse.Errors)

       {"success":"false","message":"Error..." }

   #end

#end

Can you please suggest what modification should I need to make in the velocity script above to add extended attributes while creating a custom group.

Thanks.

Verified Answer
  • Looking at it yes, your extended attribute syntax looks right
     
    Patrick Mason
    Development Lead- Extensibility
    o: 214.420.1329
    telligent.com
     
    From: anandabakhal [mailto:bounce-anandabakhal@communities.telligent.com]
    Sent: Friday, April 27, 2012 8:02 AM
    To: bugsandissues@communities.telligent.com
    Subject: RE: [Bugs and Issues - Telligent Community] Create Group With Extended attribute through Widget API
     

    Hello Patrick,

    Thanks for the suggestion. can you please confirm if following snippet is correct to create new group with extended attributes:

    #set($groupResponse = $core_v2_group.Create("Test Group", "PrivateUnlisted", "%{AutoCreateApplications = false,_ExtendedAttributes_FirstName = '$firstName',_ExtendedAttributes_MiddleName = '$middleName',_ExtendedAttributes_Surname = '$surname',_ExtendedAttributes_Gender = '$gender'}"))

    /br

All Replies
  • anandabakhal, these are now supported in the 6.1 REST APIs but I can't see support in the widget api for extended attributes. Perhaps make a seperate call to the REST api to update the group extended attributes instead or create a widget extension plugin to wrap the request?:

    CREATE 6.1:

    telligent.com/.../21791.create-a-group-6-1.aspx

    UPDATE 6.1:

    telligent.com/.../21792.update-a-group-6-1.aspx

  • You can update Extended Attributes in studio widgets if you running 6.1 or higher.
     
    Basically you add it to the options dictionary like any other property but take the name of your extended attribute and prepend _ExtendedAttributes_
     
    Example for group update:
     
    $core_v2_group.Update(1234,”%{Description=’Some new description’,_ExtendedAttributes_myAttributeName=’somevalue’, ,_ExtendedAttributes_myAttributeName2=’somevalue2’}”)
     
    Patrick Mason
    Development Lead- Extensibility
    o: 214.420.1329
    telligent.com
     
    From: Adam Seabridge [mailto:bounce-aseabridgethebuildingblockscouk@communities.telligent.com]
    Sent: Wednesday, April 25, 2012 6:00 AM
    To: bugsandissues@communities.telligent.com
    Subject: RE: [Bugs and Issues - Telligent Community] Create Group With Extended attribute through Widget API
     

    anandabakhal, these are now supported in the 6.1 REST APIs but I can't see support in the widget api for extended attributes. Perhaps make a seperate call to the REST api to update the group extended attributes instead or create a widget extension plugin to wrap the request?:

    CREATE 6.1:

    telligent.com/.../21791.create-a-group-6-1.aspx

    UPDATE 6.1:

    telligent.com/.../21792.update-a-group-6-1.aspx

  • Thats good to know Partick. It looks like the same format as how you set the user profile fields for a user in the widget api.

    How come the widget api documentation doesn't expose this information though? I can't see it listed in the 6.1 site we are running here: /controlpanel/ApiDocumentation/Extension.aspx?name=core_v2_group&api=widget#Update

  • It is identical to profile fields J
     
    We are enhancing documentation in the next version I can see if this would be better handled, but at minimum we need to get some documentation out on Telligent.com for it
     
    Patrick Mason
    Development Lead- Extensibility
    o: 214.420.1329
    telligent.com
     
    From: Adam Seabridge [mailto:bounce-aseabridgethebuildingblockscouk@communities.telligent.com]
    Sent: Wednesday, April 25, 2012 8:52 AM
    To: bugsandissues@communities.telligent.com
    Subject: RE: [Bugs and Issues - Telligent Community] Create Group With Extended attribute through Widget API
     

    Thats good to know Partick. It looks like the same format as how you set the user profile fields for a user in the widget api.

    How come the widget api documentation doesn't expose this information though? I can't see it listed in the 6.1 site we are running here: /controlpanel/ApiDocumentation/Extension.aspx?name=core_v2_group&api=widget#Update

  • That would be good. Whilst I think about it I remember seeing somewhere about how we can comment our custom extension methods so that the description information is passed back to the documentation here: ApiDocumentation/Extension.aspx.

    Do you have any details on this? it was something like this:

    public string MyExtensionMethod(int postId) [a description of my method here]

    {

    }

    Also any chance you can kick kjopesko? by the way as he is spamming the forums.

  • Yes, you decorate using [Documentation(“test”)]  attribute or it has several named parameters instead of a string, specifically good for decorating arguments.  I will have to track down the full namespace if you cannot find it.
     
    Patrick Mason
    Development Lead- Extensibility
    o: 214.420.1329
    telligent.com
     
    From: Adam Seabridge [mailto:bounce-aseabridgethebuildingblockscouk@communities.telligent.com]
    Sent: Wednesday, April 25, 2012 9:57 AM
    To: bugsandissues@communities.telligent.com
    Subject: RE: [Bugs and Issues - Telligent Community] Create Group With Extended attribute through Widget API
     

    That would be good. Whilst I think about it I remember seeing somewhere about how we can comment our custom extension methods so that the description information is passed back to the documentation here: ApiDocumentation/Extension.aspx.

    Do you have any details on this? it was something like this:

    public string MyExtensionMethod(int postId) [a description of my method here]

    {

    }

    Also any chance you can kick kjopesko? by the way as he is spamming the forums.

  • Hello Patrick,

    Thanks for the suggestion. can you please confirm if following snippet is correct to create new group with extended attributes:

    #set($groupResponse = $core_v2_group.Create("Test Group", "PrivateUnlisted", "%{AutoCreateApplications = false,_ExtendedAttributes_FirstName = '$firstName',_ExtendedAttributes_MiddleName = '$middleName',_ExtendedAttributes_Surname = '$surname',_ExtendedAttributes_Gender = '$gender'}"))

    /br

  • Looking at it yes, your extended attribute syntax looks right
     
    Patrick Mason
    Development Lead- Extensibility
    o: 214.420.1329
    telligent.com
     
    From: anandabakhal [mailto:bounce-anandabakhal@communities.telligent.com]
    Sent: Friday, April 27, 2012 8:02 AM
    To: bugsandissues@communities.telligent.com
    Subject: RE: [Bugs and Issues - Telligent Community] Create Group With Extended attribute through Widget API
     

    Hello Patrick,

    Thanks for the suggestion. can you please confirm if following snippet is correct to create new group with extended attributes:

    #set($groupResponse = $core_v2_group.Create("Test Group", "PrivateUnlisted", "%{AutoCreateApplications = false,_ExtendedAttributes_FirstName = '$firstName',_ExtendedAttributes_MiddleName = '$middleName',_ExtendedAttributes_Surname = '$surname',_ExtendedAttributes_Gender = '$gender'}"))

    /br

  • Thanks !!!