Search This Blog

Wednesday, August 21, 2013

Node Js Plugin with Eclipse

       There are so many editors supporting Javascript. But I feel Eclipse as a comfortable one as this is one stop for everything. Till now I have worked on different frameworks of Java and felt Eclipse as the best for debugging and even for remote debugging also. When I started to work for Node JS, I was trying to find some best editors and debugging tools. Tried so many and finally came back to Eclipse. There is a very good plugin available for Node in Eclipse.

       NodeEclipse gives you all the details about the different plugins available. Github site for NodeEclipse gives you all the details about the usage of hese plugins also. Two different sets called ENIDE and NODE NTS are available for Node JS. There are very minor differences in between them. If you carefully observe the below listings, the only difference is ENIDE has some extra editors which support coffee script and also a REST client which is good for debugging purpose.

Friday, August 16, 2013

Dynamic SOQL for setting fields or relationships

In apex, objects can be created and manipulated dynamically. The only thing that needs to be known is Object Name.

Salesforce maintains a static object called 'Schema'. This will contain information about all the objects in the org in a map format. If the object is a standard object, the key will be just it's name. For custom objects, they are maintained under key as 'NamespacePrefix__'+'Object Name'+'__c'. For example, if the namespace is nspTest and the object name is Tester, then the key will be 'nspTest__Tester__c'. This complete name is called as API name.

Every Object in salesforce is inherited from "sObject" and is related to a schema. The information about the object is called "describe". It includes the fields related to this objects, child relationships like the lookup's master-childs etc.... If the field it custom field, the name will have '__c' suffix.

Schema.SObjectType targetType = Schema.getGlobalDescribe().get(sObjName);
Map fieldMap = targetType.getDescribe().fields.getMap();
Schema.SObjectField sField = fieldMap.get(fieldToUpdate);