Lower User Roles not allowed to create higher Role

Know that one gives error in similar situation but can never remember which way round.

Interesting read.

Iā€™m feeling very noob like and so have no idea how to do JScript. However, I believe if I can learn this, then the possibilities are then endless? Adding a product for starters!

Do I just put it in a notepad and tell Samba to open it?

Automation COmmands > Scriptā€¦ doh

Thatā€™s made me lol a little

1 Like

@QMcKay Thanks loads for doing the above, appreciate it.

Have had a crash error.

Pretty sure its this?

Message: Expected ā€˜)ā€™


-----------------------------
[General Info]

Application: SambaPOS
Version:     5.1.60
Region:      en
DB:          SQ
Machine:     DESKTOP-0174DOV
User:        Shakes
Date:        05/10/2016
Time:        18:41

User Explanation:

Shakes said ""
-----------------------------

[Exception Info 1]

Top-level Exception
Type:        System.Reflection.TargetInvocationException
Message:     Exception has been thrown by the target of an invocation.
Source:      mscorlib
Stack Trace: at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

Inner Exception 1
Type:        Microsoft.ClearScript.ScriptEngineException
Message:     Expected ')'
Source:      ClearScript
Stack Trace: at Microsoft.ClearScript.ScriptEngine.ThrowScriptError(IScriptEngineException scriptError)
   at Microsoft.ClearScript.Windows.WindowsScriptEngine.ThrowScriptError(Exception exception)
   at Microsoft.ClearScript.Windows.WindowsScriptEngine.<>c__DisplayClass51_0`1.<ScriptInvoke>b__0()
   at Microsoft.ClearScript.ScriptEngine.ScriptInvoke[T](Func`1 func)
   at Microsoft.ClearScript.Windows.WindowsScriptEngine.ScriptInvoke[T](Func`1 func)
   at Microsoft.ClearScript.Windows.WindowsScriptEngine.Execute(String documentName, String code, Boolean evaluate, Boolean discard)
   at Samba.Services.Implementations.ExpressionModule.ExpressionEngine.Invoke(String expression, String function, Object dataObject, Object[] args)
   at Samba.Services.Implementations.ExpressionModule.ExpressionService.InvokeScript(String handlerFunction, Object dataObject)
   at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2)
   at Samba.Modules.AutomationModule.ActionProcessors.ExecuteScript.Process(ActionData actionData)
   at Samba.Services.Common.RuleActionTypeRegistry.ProcessAction(String actionType, ActionData actionData)
   at Samba.Services.Implementations.AutomationModule.AutomationService.ProcessAction(String actionType, ActionData actionData)
   at Samba.Modules.AutomationModule.AutomationModule.<OnInitialization>b__5_0(EventParameters`1 x)
   at Microsoft.Practices.Prism.Events.EventSubscription`1.InvokeAction(Action`1 action, TPayload argument)
   at Microsoft.Practices.Prism.Events.EventSubscription`1.<>c__DisplayClass2.<GetExecutionStrategy>b__0(Object[] arguments)
   at Microsoft.Practices.Prism.Events.EventBase.InternalPublish(Object[] arguments)
   at Microsoft.Practices.Prism.Events.CompositePresentationEvent`1.Publish(TPayload payload)
   at Samba.Presentation.Services.Common.ExtensionMethods.Publish[TEventsubject](TEventsubject eventArgs, String eventTopic, Action expectedAction)

-----------------------------

[Assembly Info]

mscorlib, Version=4.0.0.0
Samba.Services, Version=1.0.0.0
Samba.Domain, Version=1.0.0.0
Samba.Infrastructure.Data, Version=1.0.0.0
System.ComponentModel.Composition, Version=4.0.0.0
System.Core, Version=4.0.0.0
PresentationCore, Version=4.0.0.0
DevExpress.Xpf.LayoutControl.v14.1, Version=14.1.13.0
System.Xml, Version=4.0.0.0
DevExpress.Xpf.Grid.v14.1, Version=14.1.13.0
System, Version=4.0.0.0
DevExpress.Xpf.Grid.v14.1.Core, Version=14.1.13.0
WindowsBase, Version=4.0.0.0
System.Xaml, Version=4.0.0.0
PresentationFramework, Version=4.0.0.0
Samba.Infrastructure, Version=1.0.0.0
Microsoft.Practices.Prism, Version=4.0.0.0
System.Runtime.Serialization, Version=4.0.0.0
Microsoft.Practices.Prism.MefExtensions, Version=4.0.0.0
DevExpress.Xpf.Core.v14.1, Version=14.1.13.0
Samba.Presentation.Services, Version=1.0.0.0
System.Windows.Forms, Version=4.0.0.0
System.Drawing, Version=4.0.0.0
Stateless, Version=1.0.0.0
Samba.Persistance, Version=1.0.0.0
PropertyTools, Version=2012.4.14.1
Samba.Localization, Version=1.0.0.0
ReachFramework, Version=4.0.0.0
EntityFramework, Version=6.0.0.0
FluentValidation, Version=3.4.0.0
Omu.ValueInjecter, Version=2.3.0.0
Microsoft.Practices.ServiceLocation, Version=1.0.0.0
Microsoft.CSharp, Version=4.0.0.0

-----------------------------

[System Info]

Operating System
-Microsoft Windows 10 Pro
--CodeSet = 1252
--CSDVersion = 
--CurrentTimeZone = 60
--FreePhysicalMemory = 789172
--OSArchitecture = 64-bit
--OSLanguage = 2057
--ServicePackMajorVersion = 0
--ServicePackMinorVersion = 0
--Version = 10.0.14393

Machine
-DESKTOP-0174DOV
--Manufacturer = TOSHIBA
--Model = Satellite C650D
--TotalPhysicalMemory = 4021178368
--UserName = DESKTOP-0174DOV\Shakes

-----------------------------

In the JScript code I changed:

var grp = 'Employee';

Is your user role called Employee?

1 Like

the user role is called employee, yes

just double checked cos I started to have doubtsā€¦ no it actually is lol

I noticed that it said User ID in the script?

So I looked at the tables in the ssms and the ID I needed was 4, so I tried that and still threw the above error

EDIT:

I also notice my table isnā€™t called [USERS] its called [dbo].[Users]

/****** Script for SelectTopNRows command from SSMS ******/
SELECT TOP (1000) [Id]
,[PinCode]
,[Name]
,[UserRole_Id]
FROM [SambaPOS5].[dbo].[Users]

EDIT:

Tried changing the above values with the same error

I had no idea what you were talking about LOL, thought you were coming back to YAML product import after saying adding productsā€¦ hehe

1 Like

Its got ID because Q already put the lookup for get the ID.
ID is in the users table to link to the role, but he made so you could put in the string of the role name rather than the id itself, the first qury gets the is based on the role name and then uses that for the user table insertā€¦

1 Like

Just testing and also seem to be getting errorā€¦

1 Like

Aha ok gotcha.

Either way itā€™s always throwing above error.

Iā€™ve checked and cannot see a missing ) anywhere

Missing ) is on the ends of the more verification;

usr = (typeof usr === 'undefined' ? '' : usr);
pin = (typeof pin === 'undefined' ? '' : pin);
grp = (typeof grp === 'undefined' ? '' : grp);

but still get error.

Isnā€™t anything to do with my tables starting with [dbo]?

No, they all are, ignore that.

1 Like

Ok lol :smiley:

Once we get this working Iā€™ll be making myself a JSCRIPT to create staff entity too so my switch user will work

It should be [Id] not UserRole_Id as thats the role column in users table.

Q must be tired, hes usually s**t hot for SQL. :wink:

2 Likes

Let me try! Morecharecters