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
shravanshravan 

updating field in javascript

Hi All,

 

My requirement is:

 

In a search(search means :click on any object---->click on go---> here we are selecting multiple checkboxes),added one button(Update). On click of button implemented java script code as a

-------------------------------------------------------------------------------------

{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")};
    var url = parent.location.href;
    var records = {!GETRECORDIDS($ObjectType.WLM_Work_Request__c)};
    var updateRecords = [];
 
    if (records[0] == null) {
        alert('Please select at least one record to take ownership');
    }
    else {
        for (var a=0; a<records.length; a++ )
        {
                                                  
            var update_Engineer = new sforce.SObject("WLM_Work_Request__c");
                                                   
            update_Engineer.Id = records[a];
                                      
            update_Engineer.Assigned_EngineerId__c= '{!User.Id}';
                                                   
            update_Engineer.OwnerId = '{!User.Id}';
                                                    
            updateRecords.push(update_Engineer);
                                                   
                                                    
        }
        result = sforce.connection.update([updateRecords]);
        alert('Processing6666666666......');
 
    parent.location.href = url;
    }

--------------------------------------------------------------------------------------------------

 

problem is: field is not updating but I am getting processing6666666666 alert.

Navatar_DbSupNavatar_DbSup

Hi,

Try the below code:

{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")};

    var url = parent.location.href;

    var records = {!GETRECORDIDS($ObjectType.WLM_Work_Request__c)};

    var updateRecords = [];

 

    if (records[0] == null) {

        alert('Please select at least one record to take ownership');

    }

    else {

        for (var a=0; a<records.length; a++ )

        {

                                                 

            var update_Engineer = new sforce.SObject("WLM_Work_Request__c");

                                                  

            update_Engineer.Id = records[a];

                                     

            update_Engineer.Assigned_EngineerId__c= '{!User.Id}';

                                                   

            update_Engineer.OwnerId = '{!User.Id}';

                                                   

            updateRecords.push(update_Engineer);

                                                  

                                                    

        }

        result = sforce.connection.update(updateRecords);

        alert('Processing6666666666......');

 

   window.location.reload();

    }

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.