Desktop version

Main > Forum > Learning > 1C Junior Developer Course > Can not call an AtServer method from an AtClient method when both are inside same Common Module

Forum

Search UsersRules
Can not call an AtServer method from an AtClient method when both are inside same Common Module
#1
Just came
Points:: 0
Joined:: Apr 5, 2021

I have create a Common Module, with thes three properties checked: Client, Server and Server call.
Here is the code (The Common Module name is ServiceSrv):

Code
&AtClient
Function ClientMethod() Export
   ServiceSrv.ServerMethod();
   Return "";
EndFunction

&AtServer
Procedure ServerMethod() Export
   // TODO
EndProcedure



Then, I have an AtClient method that calls an AtServer method, both are defined inside the same Common module, but when I run the application and execute the AtClient method from a Common Form, an error raises saying "Object module not found (MethodServer)"

What is wrong here?

Profile
#2
Administrator
Points:: 0
Joined:: Oct 3, 2019

Hi Roberto,

in your case, you don't need to specify the "&AtClient" and "&AtServer" prefixes. Since the place of code execution, in this case, is determined by the settings of the Common module, and you have enabled the "Server" and "Client" flags for your module.

Accordingly, the code should look like this:


Code
Function ClientMethod() Export 
   ServerMethod();
   Return "";
EndFunction


Procedure ServerMethod() 
   
EndProcedure


If we want the code to be executed strictly on the server, then we must create a separate module with "Server = True", create an export procedure in this module, and call this procedure from the module with "Client = True".

You can read more details here: https://1c-dn.com/blog/program-modules-in-1c-where-the-developer-can-create-his-code/

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.