This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to load user's information from a SBM table to a created the SBM Role automatically

We have a SMB project, there is a table called Suppliers, which has hundreds of suppliers’ individual information. We also created a Supplier Role in this project. Instead of setting one person to Supplier Role group from the SBM workCenter manually, how can we load all individual information from the Suppliers table to Supplier Role automatically?

Thank you

Parents
  • 0  

    To clarify, in SBM, roles and groups are ways to assign privileges to users:

    • a role is created in Composer and attached to the application.
    • a group is defined in SBM Application Administrator.

    You can add users to either level, but I would recommend adding users to a group, and then assigning a group to a role. Groups are easier to manage privileges and you can run system reports to see who is in the group.

    To answer your question, if I understand correctly, the user accounts do not exist at all in SBM, but the user information is in the suppliers table. You want to add these individuals as actual users within SBM (note that this does require the appropriate additional user licenses for SBM).

    For adding new users, I usually resort to using an orchestration as I trust that functionality better. Here are the steps that i would take:

    1. I would create a group for your suppliers, associating the correct role with that group
    2. Create one supplier to act as a template user associate with group created in 1 and add any other additional information.
    3. Create an orchestration, which runs a report of all records in the suppliers table, and then create users for each record, using the template user created in step 2.

    Now if you already have the users in SBM and you just want to add them to the group, you can do the same as above, just updating the user account.

    If the users are already I added, I choose modscript to automatically add users. I use the following snippet often on transitions where a user is selected in a field, but may not yet be part of the correct permission group to own the item yet. The script searches for the group by name, and if that particular userId is not in the group, then it adds it.

    def addToGroup(userId){
        var groupName = "Group Name";
        //check if member
        var group = Ext.CreateAppRecord (Ext.TableId("TS_GROUPS"));
        group.ReadWithWhere("TS_NAME='${groupName}'");
        var grpId = group.GetId();
            
        var member = Ext.CreateAppRecord (Ext.TableId("TS_MEMBERS"));
        var qs2 = "TS_USERID = ${userId} AND TS_GROUPID = ${grpId}";
        if(!member.ReadWithWhere(qs2)) {
            // add to member
            member.SetFieldValue("USERID",userId);
            member.SetFieldValue("GROUPID", grpId);
            member.SetFieldValue("ESTABLISHEDBY", 0);
            var ret = member.Add();
            if (ret == 0){
                return "Error adding to group ${groupName}.<br/>";
            } else {            
                return "Added to group ${groupName}.<br/>";
            }
        } else {
            return "";
        }
        
    }

Reply
  • 0  

    To clarify, in SBM, roles and groups are ways to assign privileges to users:

    • a role is created in Composer and attached to the application.
    • a group is defined in SBM Application Administrator.

    You can add users to either level, but I would recommend adding users to a group, and then assigning a group to a role. Groups are easier to manage privileges and you can run system reports to see who is in the group.

    To answer your question, if I understand correctly, the user accounts do not exist at all in SBM, but the user information is in the suppliers table. You want to add these individuals as actual users within SBM (note that this does require the appropriate additional user licenses for SBM).

    For adding new users, I usually resort to using an orchestration as I trust that functionality better. Here are the steps that i would take:

    1. I would create a group for your suppliers, associating the correct role with that group
    2. Create one supplier to act as a template user associate with group created in 1 and add any other additional information.
    3. Create an orchestration, which runs a report of all records in the suppliers table, and then create users for each record, using the template user created in step 2.

    Now if you already have the users in SBM and you just want to add them to the group, you can do the same as above, just updating the user account.

    If the users are already I added, I choose modscript to automatically add users. I use the following snippet often on transitions where a user is selected in a field, but may not yet be part of the correct permission group to own the item yet. The script searches for the group by name, and if that particular userId is not in the group, then it adds it.

    def addToGroup(userId){
        var groupName = "Group Name";
        //check if member
        var group = Ext.CreateAppRecord (Ext.TableId("TS_GROUPS"));
        group.ReadWithWhere("TS_NAME='${groupName}'");
        var grpId = group.GetId();
            
        var member = Ext.CreateAppRecord (Ext.TableId("TS_MEMBERS"));
        var qs2 = "TS_USERID = ${userId} AND TS_GROUPID = ${grpId}";
        if(!member.ReadWithWhere(qs2)) {
            // add to member
            member.SetFieldValue("USERID",userId);
            member.SetFieldValue("GROUPID", grpId);
            member.SetFieldValue("ESTABLISHEDBY", 0);
            var ret = member.Add();
            if (ret == 0){
                return "Error adding to group ${groupName}.<br/>";
            } else {            
                return "Added to group ${groupName}.<br/>";
            }
        } else {
            return "";
        }
        
    }

Children
  • 0 in reply to   

    Hi Michael,

    Thank you so much for your detailed response. I have created the Modscript you showed here on transitions where a user is selected in a field. I have tried the Modscript, but had validation issue. Error: "Illegal character" in 'Add Supplier'  at (2, 1). I used the Group name called "SPQ_Training_Supplier" that defined in Application Administrator. 

    This is the Group name defined in Application Administrator:

    This is the Modscript where I called in the transition: