Saturday, February 29, 2020

dynamic soql to fetch all fields of an object in salesforce using schema class

Dynamic SOQL query to fetch all fields in Salesforce Dynamic SOQL query to fetch all fields in Salesforce salesforce Dynamic SOQL query Salesforce SOQL is Salesforce Object Query Language for querying data in the Force.com platform. It is very much similar to SQL. But in SOQL, we can not query all fields from object. This statement is not allowed in SOQL: select * from Account; But there is one trick to query all fields of Object in SOQL query. In the example below, we will use SOQL query to fetch all fields of account. We have added one ‘Fetch Account’ button on page. When we will click on this button all fields of account objects are fetched using SOQL query. We have also shown SOQL query in Visualforce page result. Click for Demo Visualforce Code: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 Apex Code: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 public class selectAllSOQLExampleController { public List accList{get;set;} public String query{get;set;} public selectAllSOQLExampleController(){ } public PageReference fetch(){ String SobjectApiName = 'Account'; Map schemaMap = Schema.getGlobalDescribe(); Map fieldMap = schemaMap.get(SobjectApiName).getDescribe().fields.getMap(); String commaSepratedFields = ''; for(String fieldName : fieldMap.keyset()){ if(commaSepratedFields == null || commaSepratedFields == ''){ commaSepratedFields = fieldName; }else{ commaSepratedFields = commaSepratedFields + ', ' + fieldName; } } query = 'select ' + commaSepratedFields + ' from ' + SobjectApiName + ' Limit 5'; accList = Database.query(query); return null; } }

Monday, October 7, 2019

salesforce lightning component LWC life cycle hooks

LWC lifecycle hooks video tutorial



    
In Salesforce Lightning Web Components (LWC), lifecycle hooks are methods that allow developers to hook into the lifecycle of a component. These hooks enable you to perform actions at specific stages of a component's lifecycle, such as when the component is created, rendered, inserted into the DOM, or removed from the DOM. Here are the available lifecycle hooks in LWC along with explanations and code samples:

1. **constructor()**: This is the first lifecycle hook called when a component is created. It is used for initializing component state or setting up i
nitial values.

```javascript
import { LightningElement } from 'lwc';

export default class MyComponent extends LightningElement {
    constructor() {
        super();
        // Initialize state or perform setup tasks
    }
}
```

2. **connectedCallback()**: This lifecycle hook is called when the component is inserted into the DOM. It's commonly used for setting up event listeners or performing one-time initialization tasks.

```javascript
import { LightningElement } from 'lwc';

export default class MyComponent extends LightningElement {
    connectedCallback() {
        // Perform setup tasks or attach event listeners
    }
}
```

3. **renderedCallback()**: This hook is called after the component's template has been rendered and is applied to the DOM. It's useful for interacting with the DOM after rendering has occurred.

```javascript
import { LightningElement } from 'lwc';

export default class MyComponent extends LightningElement {
    renderedCallback() {
        // Interact with the DOM after rendering
    }
}
```

4. **disconnectedCallback()**: This hook is called when the component is removed from the DOM. It's used for cleanup tasks like removing event listeners or resetting state.

```javascript
import { LightningElement } from 'lwc';

export default class MyComponent extends LightningElement {
    disconnectedCallback() {
        // Clean up tasks like removing event listeners
    }
}
```

5. **reconnectedCallback()**: This hook is called when the component is removed from the DOM and then inserted back into the DOM. It's useful for reinitializing state or performing setup tasks after the component is reinserted.

```javascript
import { LightningElement } from 'lwc';

export default class MyComponent extends LightningElement {
    reconnectedCallback() {
        // Reinitialize state or perform setup tasks
    }
}
```

6. **errorCallback()**: This hook is called when there's an error during rendering, updating, or within an event handler. It's used for error handling and logging.

```javascript
import { LightningElement } from 'lwc';

export default class MyComponent extends LightningElement {
    errorCallback(error, stack) {
        // Handle errors or log them
    }
}
```

These lifecycle hooks provide flexibility and control over the behavior of your Lightning Web Components at various stages of their lifecycle. Utilize them according to your component's requirements for initialization, cleanup, and interaction with the DOM.


Wednesday, August 28, 2019

MAlware found in camscanner

Wednesday, May 8, 2019

Correct Web-app xml dependency for JBoss and netbeans webservice in java

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">

Friday, May 3, 2019

How to delete class or trigger from salesforce production org

Print this page
Disable or delete an Apex Class or Trigger from a Production Organization
Knowledge Article Number 000006188
Description

An Apex Class or Trigger must be removed from a production instance if it's blocking a deployment or is no longer needed. Since Apex code can't be modified directly within a Production organization, so it requires steps using Developer tools, like the Force.com IDE.

Important: This is the only way an Administrator or Developer can disable or remove Apex in Production.
Resolution

Steps to Remove or Disable

1. Force.com IDE should be installed.
2. Connect to the Sandbox Instance using the IDE and find the class or trigger that you want to delete.
3. Open the matching .xml file, and change the Status XML tag from Active to Deleted.
4. Or to disable the trigger change it to Inactive.
Note: Apex class Status can only be changed to "Active" or "Deleted," not "Inactive".
5. Save the file.
6. Select the two files (Code and XML) using "Ctrl-click," and then right-click on one of them.
7. Select Force.com | Deploy to server.
8. Provide your credentials for the Production org and follow the steps.