Is it possible to use jsforce to achieve Schema.DescribeFieldResult? - salesforce

wondered if anyone has used jsForce to retrieve metadata about custom fields - per what is possible via the DescribeFieldResult call described here - https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_fields_describe.htm
Any pointers are appreciated!

Call the REST API "describe", for example /services/data/v56.0/sobjects/Account/describe
Or write a piece of Apex that would run your describe call and expose it as a REST service using #HttpGet for example. Then call it with apexrest in the URL

Related

Extjs 6 How to use Promise in Proxy?

I use a external library to fetch some data. To get some data I just type:
this.service.query(...args)
It returns a Promise<[]>.
What kind of a Exta.data.proxy.Proxy I should extend/use?
I don't want fetch date before and then create a Store with a memory proxy.
There is no functional proxy for your needs, but in my opinion you should extend a Ext.data.proxy.Server.
You must override doRequest function.
See Ext.data.proxy.Ajax for example (which is based on Ext.data.proxy.Server).
You can use a Ext.ajax.request, it returns a promise which you can use to create a store using Ext.create and store.loadData

Mono embed API modifying method body at runtime

Is it possible to modify a method body at runtime using mono embed API. Is there is a way to access method's body and signature. I know it's a little bit complicated but I really need it for a school project.
I was able to do this with the .Net framework. I found out that the .Net framework resolves all the methods at the managed code and there is an external method called SetmethodIL which I had to call using refelection and It worked but mono takes a different route. Mono takes the unmanaged code choice which calls an external method called create_runtime_class that gets the job done.
Thank you for your support.
I found out by examining the reflection_methodbuilder_to_mono_method method that a MonoMethod must have a MonoMethodHeader which contains information about the method.
At the line 3014 you will see how they were able to set the code of the method by passing the array address as a guint8.
As far as I know the code contains the CIL Instructions which is an array of bytes.
By using the method called mono_method_get_header you will be able to get the header of any method and by using technique above you will be able to modify the code. But I'm not sure if this gonna work or not It may only works with dynamically generated methods.
If you call an internal call with a byte array parameter to c Maybe we could get it right.

In Salesforce How can i write Select * query in SOQL with Rest call

I want to get all objects with a Rest call using the SOQL syntax.
I know that this is not possible, but there is a workaround, but I was wondering if there is a workaround using REST.
I want to achieve something like this (So I don't want to specify the fields)
/services/data/v36.0/query/?q=SELECT+name+from+Contact
Well, you'd neet to construct the query string dynamically, exactly the same way as in the workaround you linked. You just need to call describe API first.

Is there an eval() equivalent in apex/Salesforce?

I've looked into this, and it seems there is no directly related function available since Apex is so strongly typed, but I was wondering if anyone had found a workaround. I'm designing a credit risk object and my client wants to be able to insert expressions such as "150 + 3" instead of "153" when updating fields to help speed things up on her end. Unfortunately, I'm new to salesforce, so I'm having trouble coming up with ideas. Is this even feasible?
You could allow hand-entering of SOQL statements and then use dynamic SOQL to process them. But this would require a bit more than "150 + 3."
Otherwise you could do this in JavaScript and pass the value back to Apex as an already calculated number.
It is possible to mimic a Javascript eval() in Apex by making a callout to the executeAnonymous API method on either the Tooling or Apex API.
The trick is you need to pass any required input parameters in the eval string body. If a response is required you need a mechanism to extract it.
There are two common ways you can get a response back from executeAnonymous.
Throw a deliberate exception at the end of the execute and include the response. Kevin covers this approach in EVAL() in Apex. Secure Dynamic Code Evaluation on the Salesforce1 Platform.
I used a variation of this approach but returned the response via the debug log rather than an intentional exception. See Adding Eval() support to Apex.
Using my example the Apex would be something like:
integer sum = soapSforceCom200608Apex.evalInteger(
'integer result = 150 + 3; System.debug(LoggingLevel.Error, result);');
You might not be able to perform the callout during member initialisation or in a constructor.
Incidentally, the Salesforce Stackexchange site is a great place to ask Salesforce specific questions.
Script.apex can help with evaulating javascript expressions. Check this out. https://github.com/Click-to-Cloud/Script.apex. It is just as simple as this.
Integer result = (Integer)ScriptEngine.getInstance().eval('1 + 2');

Modify Endpoint Address of a WCF Client Proxy

When I'm making web service calls from Silverlight using a service reference, is there any way to have the (generated) SoapClient objects modify the address that they call the service on?
Specifically, I'd like to tack on a QueryString value onto each call that the service makes. So if I have
DataService.SilverlightServiceSoapClient C = new DataService.SilverlightServiceSoapClient();
Is there any way to do something like:
C.Address += "?Foo=Bar";
Which would allow me to, from my WebMethod, say:
HttpContext.Current.Request.QueryString["foo"];
Obviously I can modify my WebMethods to take this value in as a parameter, but I'd like to avoid doing that if possible.
Since you are already using service references, you can simply use the overload of the proxy class constructor that accepts an EndpointAddress as a parameter. Alternatively, you can create multiple endpoint configuration and have the code simply use the chosen configuration - which may include URL changes.
See Understanding Generated Client Code on MSDN.
It looks like the best way to do this is to just use one of the overloaded constructors and supply the uri yourself
C = new DataService.SilverlightServiceSoapClient(new BasicHttpBinding(), new System.ServiceModel.EndpointAddress("http://blah/blah/blah/SilverlightService.asmx?Foo=Bar"));

Resources