Can not call an AtServer method from an AtClient method when both are inside same Common Module

For students who study 1C Junior course.

#1
People who like this:0Yes/0No
Just came
Rating: 0
Joined: Apr 5, 2021
Company:

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?

 
#2
People who like this:0Yes/0No
Administrator
Rating: 14
Joined: Oct 3, 2019
Company:

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/

 
Subscribe
Be the first to know tips & trick on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.