function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Tania B GarciaTania B Garcia 

Apex controller isn´t work

Hi

I made an apex class where certain information from lead fields is sent through a server to an http address of a POST method in the form of urlencoded.
In this same apex a lightning resource was made, it has a component that is used for a button that is in lead, when you press the button a window appears where you have to fill in a field called "razón de envío" and then clic to the send button, there is also a controller which confirms that the request has been sent successfully or that it failed.

In this case there are 2 things that I need to help me
  1. At the moment of sending the request to the server of the http address, it answers with a status code, I want to take that status code that responds and if it is successful in this case 200, I need to turn on a check box field in salesforce.
  2. When I implemented point 1, at the time of testing the complete operation I realized that the controller is no longer working since the alert that was set to know if it was controlled correctly or not was not going out
Therefore I do not know why the controller no longer works and what is the best way to update the check box field.
I put the code that I am using, some things are in Spanish because our client speaks Spanish
User-added imageUser-added imageUser-added imageUser-added image

 
Best Answer chosen by Tania B Garcia
Tania B GarciaTania B Garcia
Hi
What I did to solve this case was to put the console.log also use the let toast params and treat the error that will return it to me differently and in the end I could also update the field I needed when it was successful
I share a piece of my code where it is successful and fails
User-added image

All Answers

Suraj Tripathi 47Suraj Tripathi 47
Hi Tania,

Your coding implementation is good but you should use Console.log to check the output value of your code.
put the controller's return value in a variable and use console.log to print the value.
this way you can track your code.
---------------
If you find your Solution then mark this as the best answer to close this question. 

Thank you!
Regards,
Suraj Tripathi
Tania B GarciaTania B Garcia
Hi Suraj

Sorry, I don't really understand where I should place the Console.log, it has to be in the controller and in my code where I have the lead query?

Thanks and Regards
Tania B GarciaTania B Garcia
Hi
What I did to solve this case was to put the console.log also use the let toast params and treat the error that will return it to me differently and in the end I could also update the field I needed when it was successful
I share a piece of my code where it is successful and fails
User-added image
This was selected as the best answer