Clone
|
DeepClone
|
If a list is cloned, it duplicates it and has reference.
|
If a list is DeepCloned, it duplicates and doesn’t have any reference.
|
Primitive data types are supported.
|
Primitive data types are not supported.
|
Parameters:
Not applicable
|
Parameters:
Boolean opt_preserve_id – Whether cloned sObjects records ids are maintained.
Boolean opt_preserve_readonly_timestamps– Whether cloned sObjects records read only system fields like createdDate, LastModifiedDtate, etc are maintained.
Boolean opt_preserve_autonumbe– Whether cloned sObjects records auto number fields are maintained.
|
Sample Code:
Account Account1= new Account(Name='Test1');
Account Account2= new Account(Name='Test2');
List<Account> AccountList = new List<Account>{Account1, Account2};
List<Account> listDuplicate = new List<Account>();
listDuplicate = AccountList.clone();
AccountList.get(0).Name = 'Testing1';
system.debug(AccountList.get(0).Name + ',' + listDuplicate.get(0).Name);
Now AccountList.get(0).Name and listDuplicate get(0).Name will be ‘Testing1’.
listDuplicate.get(0).Name = 'Testing2';
system.debug(AccountList.get(0).Name + ',' + listDuplicate.get(0).Name);
Now AccountList.get(0).Name and listDuplicate get(0).Name will be ‘Testing2’.
|
Sample Code:
Account Account1= new Account(Name='Test1');
Account Account2= new Account(Name='Test2');
List<Account> AccountList = new List<Account>{Account1, Account2};
List<Account> listDuplicate = new List<Account>();
listDuplicate = AccountList.deepClone();
AccountList.get(0).Name = 'Testing1';
system.debug(AccountList.get(0).Name + ',' + listDuplicate.get(0).Name);
Now AccountList.get(0).Name will be ‘Testing1’ and listDuplicate get(0).Name will be ‘Test1’.
listDuplicate.get(0).Name = 'Testing2';
system.debug(AccountList.get(0).Name + ',' + listDuplicate.get(0).Name);
Now AccountList.get(0).Name will be ‘Testing1’ and listDuplicate get(0).Name will be ‘Testing2’.
|
Cloning
Synchronous and Asynchronous Calls with the AJAX Toolkit
AJAX Toolkit allows to issue synchronous or asynchronous calls. Asynchronous calls allow the client side process to continue, waiting for a call back from the server. To issue an asynchronous call, you must include an additional parameter with the API call, referred to as a callback function. Once the result is ready, the server invokes the callback method with the result.
sforce.connection.method("arg1","arg2", ...);
sforce.connection.login("MyName@MyOrg.com","myPassword1");
method("arg1","arg2", ..., callback_method);
var callback = {onSuccess: handleSuccess, onFailure: handleFailure};
function handleSuccess(result) {}
function handleFailure(error) {}
sforce.connection.query("Select name from Account", callback);
Field Dependency
- • The field that drives filtering is called the "controlling field." Standard and custom checkboxes and picklists (Multi-select picklist not allowed) with at least one and less than 300 values can be controlling fields.
- • The field that has its values filtered is called the "dependent field." Custom picklists and multi-select picklists can be dependent fields.
Basic HTTP access Authentication :
When the user agent wants to send the server authentication credentials it may use the Authorization field.
The Authorization field is constructed as follows:
- The username and password are combined with a single colon.
- The resulting string is encoded using the RFC2045-MIME variant of Base64, except not limited to 76 char/line.
- The authorization method and a space i.e. "Basic " is then put before the encoded string.
For example, if the user agent uses Aladdin as the username and OpenSesame as the password then the field is formed as follows:
Aladdin:OpenSesame | base64
.. yields a string 'QWxhZGRpbjpPcGVuU2VzYW1l' that is used like so:
Authorization: Basic QWxhZGRpbjpPcGVuU2VzYW1l
-----------------------------------------------------------------
Server side:
When the server wants the user agent to authenticate itself towards the server, it must respond appropriately to unauthenticated requests.
Unauthenticated requests should return a response whose header contains a HTTP 401 Unauthorized status and a WWW-Authenticate field.[5]
The WWW-Authenticate field for basic authentication (used most often) is constructed as following:
WWW-Authenticate: Basic realm="User Visible Realm"