Roam icon indicating copy to clipboard operation
Roam copied to clipboard

Use @user_account_name in Roam

Open JAsPCn opened this issue 6 years ago • 3 comments

Hi.

I´m trying to use the standard QGIS function @user_account_name in Roam 2.7.1. But the syntax [% @user_account_name %] in the Expression or Expression String Builder in the Form Design is not working for me.

In QGIS 2.18, I can see the function is available, you can use it for example in a label. And the same label is visible in Roam.

Is there an alternate syntax for this? If it's not implemented in Roam, can it be accessed with the functions eval or val? How? If it is not possible either, can I expose the value in a plugin, and access the value from inside Roam? What syntax should I need to use?

JAsPCn avatar Jan 29 '19 10:01 JAsPCn

Probably not the best way to do it but I got this code from some where years ago. It grabs the Windows username. I put this at the end of the load function in form.py:

        if self.boundwidgets.get('created_user')!=None:
            import getpass
            self.boundwidgets['created_user'].setvalue(getpass.getuser())
        pass

bwragg avatar Mar 28 '19 08:03 bwragg

Hey @bluedogit, thats just an indenting issue. If you haven’t used python before (the language the form is written in) you might want to read this https://docs.python.org/2.0/ref/indentation.html https://docs.python.org/2.0/ref/indentation.html . Basically python code needs to be consistently indented.

Once you get the indents correct it should work. Attached is a screen show how mine looks.

On 29 Mar 2019, at 3:27 pm, bluedogit [email protected] wrote:

@bwragg https://github.com/bwragg I have been trying to do this as well and get an IndentationError. Are you able to show us your form.py so I can see where I am going wrong?

Traceback (most recent call last): File "configmanager\ui\configmanagerdialog.pyc", line 158, in projectLoaded File "configmanager\ui\treenodes.pyc", line 441, in create_children File "configmanager\ui\treenodes.pyc", line 144, in create_children File "configmanager\ui\treenodes.pyc", line 368, in create_children File "roam\project.pyc", line 711, in forms File "roam\project.pyc", line 204, in from_config File "roam\project.pyc", line 364, in loadmodule File "C:\Data\Roam\projects\Tree_Inspections\New_Tree_init.py", line 1, in File "C:\Data\Roam\projects\Tree_Inspections\New_Tree\form.py", line 28 if self.boundwidgets.get('lastupdatedby')!=None: ^ IndentationError: unexpected indent

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/roam-qgis/Roam/issues/424#issuecomment-477872529, or mute the thread https://github.com/notifications/unsubscribe-auth/AEToQzQ1oPQfA2fu_YafpUowBaGqXvTTks5vbaQ1gaJpZM4aXv76.

bwragg avatar Mar 29 '19 06:03 bwragg

Thanks @bwragg, I knew about the indenting but it was throwing an exception. Turned out the indenting needed to be whitespaces not tabs. I changed them over and off it went.

Top three line don't work but the bottom three do. Once I changed it off it went. Thanks for pointing my in the right direction about doing things on load. [image: image.png]

Andrew

On Fri, Mar 29, 2019 at 5:12 PM Benjamin Wragg [email protected] wrote:

Hey @bluedogit, thats just an indenting issue. If you haven’t used python before (the language the form is written in) you might want to read this https://docs.python.org/2.0/ref/indentation.html < https://docs.python.org/2.0/ref/indentation.html> . Basically python code needs to be consistently indented.

Once you get the indents correct it should work. Attached is a screen show how mine looks.

On 29 Mar 2019, at 3:27 pm, bluedogit [email protected] wrote:

@bwragg https://github.com/bwragg I have been trying to do this as well and get an IndentationError. Are you able to show us your form.py so I can see where I am going wrong?

Traceback (most recent call last): File "configmanager\ui\configmanagerdialog.pyc", line 158, in projectLoaded File "configmanager\ui\treenodes.pyc", line 441, in create_children File "configmanager\ui\treenodes.pyc", line 144, in create_children File "configmanager\ui\treenodes.pyc", line 368, in create_children File "roam\project.pyc", line 711, in forms File "roam\project.pyc", line 204, in from_config File "roam\project.pyc", line 364, in loadmodule File "C:\Data\Roam\projects\Tree_Inspections\New_Tree_init.py", line 1, in File "C:\Data\Roam\projects\Tree_Inspections\New_Tree\form.py", line 28 if self.boundwidgets.get('lastupdatedby')!=None: ^ IndentationError: unexpected indent

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub < https://github.com/roam-qgis/Roam/issues/424#issuecomment-477872529>, or mute the thread < https://github.com/notifications/unsubscribe-auth/AEToQzQ1oPQfA2fu_YafpUowBaGqXvTTks5vbaQ1gaJpZM4aXv76 .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/roam-qgis/Roam/issues/424#issuecomment-477881146, or mute the thread https://github.com/notifications/unsubscribe-auth/AK16R90ihrSxMh8dpTqp0JKVxZDC_U9Xks5vba7AgaJpZM4aXv76 .

bluedogit avatar Mar 29 '19 08:03 bluedogit