• suji srinivasan
  • NEWBIE
  • 275 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 51
    Questions
  • 56
    Replies
Hi, i created a static resource to attach my logo in salesforce.then i copied the url and inserted in vf page .
i used the following code
<img src="https://ayush--recruitmen--c.visualforce.com/resource/1659528741000/ayushLogo?" style="width:250px;height:50px;" />.
My logo is not visible .it showing like this in preview . can anyone tell me why it is not visible. the image which i attached was jpeg format.
User-added image
thanks in advance

Hi,
npm and node are installed succesfully .
i confirmed its installation in command prompt
npm -8.11.0
node -v16.16.0

then i ran this command in vscode  to install  packages -------->npm install -g node-gyp  -------> got 0 vulnerabilities.
unable to install  npm install -g windows-build-tools
got following error


PS C:\Users\Sujis\Desktop\VScode\Hello world> npm install -g windows-build-tools
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated windows-build-tools@5.2.2: Node.js now includes build tools for Windows. You probably 
no longer need this tool. See https://github.com/felixrieseberg/windows-build-tools for details.
npm ERR! code 1
npm ERR! path C:\Users\Sujis\AppData\Roaming\npm\node_modules\windows-build-tools
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node ./dist/index.js
Downloading python-2.7.15.amd64.msi
npm ERR! [>                                            ] 0.0% (0 B/s)
npm ERR! Downloaded python-2.7.15.amd64.msi. Saved to C:\Users\Sujis\.windows-build-tools\python-2.7.15.amd64.msi.
Downloading vs_BuildTools.exe
npm ERR! [>                                            ] 0.0% (0 B/s)
npm ERR! Downloaded vs_BuildTools.exe. Saved to C:\Users\Sujis\.windows-build-tools\vs_BuildTools.exe.
npm ERR!
npm ERR! Starting installation...
npm ERR! Please restart this script from an administrative PowerShell!
npm ERR! The build tools cannot be installed without administrative rights.
npm ERR! To fix, right-click on PowerShell and run "as Administrator".

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Sujis\AppData\Local\npm-cache\_logs\2022-08-06T05_52_30_343Z-debug-0.log
PS C:\Users\Sujis\Desktop\VScode\Hello world> 

can anyone suggest me what needs to be done ? 

 
User-added image
 
Task object have Master Detail Relationship with Phase , project objects
Project object  have Lookup relationship with program object .
API name for program lookup field in project object is inov8__Program__c
how to fetch program object values in this soql?

select name,inov8__Phase__r.inov8__Project__r.Name from inov8__PMT_Task__c 

Thanks in Advance.
Hi, i need to replace Managed package object name-Phases  in to Milestones
I replaced in tabs,labels.
there's a summary component in that package. I need to replace phase name in that component table header as well.Will it be possible?
Can we change the name of particular object in that  package (whereever the phase name Mentioned)?

Thanks in Advance
I created subcontact__c object  and created lookup relationship  with contact .child relationship Name -subcontacts

1.I tried to query child to parent  
select Name, Account.Name from Contact  - got response
2.when i trield to query grand child to parent  getting error 
select Name, Contact.Account.Name from subcontact__c - got error

Can you clarify me, why i didnt get response?
Thanks in Advance. 


Task is the child of phase
when i try to query from child to parent,grand parent great grand parent.(App which i am trying is PMT)


i am getting error as
select Name,inov8__PMT_Phase__r.inov8__PMT_Project__r.name
            ^
ERROR at Row:1:Column:13
Didn't understand relationship 'inov8__PMT_Phase__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
select Name,inov8__PMT_Phase__r.Name from inov8__PMT_Task__c

Thanks in advance
In single line , I need to display  two output fields  with space in between them.
<p> Employee ID:<b> <apex:outputText value="{!candidate__c.Employee_ID__c}" ></apex:outputText> </b> Employee Name:<b> <apex:outputText value="{!candidate__c.Employee_Name__c}"> </apex:outputText> </b> </p>

 Output Reference:    
Employee ID: ASD2589637                           Employee Name:Jennifer

Thanks in advance
I am able to fetch the standard fields in rest batch Apex. but unable to fetch the custom fields .

Thanks in advance
I got error as 'variable doesnot exist' for my fields .(Highlighted fields for which i am getting error)
This is my code:
global class RecruitmentCalloutBatch implements Database.Batchable<sObject>,Database.AllowsCallouts {
     
     global Database.QueryLocator start(Database.BatchableContext BC) {
         String query = 'Select Id,Name,OwnerId,ParentId,Zone__c,ExternalAccId__c,Phone,Fax,Website,Type,Industry,Description,NumberOfEmployees,AnnualRevenue from Account';
         return Database.getQueryLocator(query);
 }

     global void execute(Database.BatchableContext BC, List<Account> Accrecords) { 
           
         HttpRequest req = new HttpRequest();
        String accquery='select+Id,Name,OwnerId,ParentId,Zone__c,ExternalAccId__c,Phone,Fax,Website,Type,Industry,Description,NumberOfEmployees,AnnualRevenue+from+Account';
        req.setEndpoint('callout:Recruitmen/services/data/v49.0/query/?q='+accquery);
        req.setMethod('GET');
        Http http = new Http();
        HTTPResponse resp = http.send(req);
        //This response will have all the data records in json structure
        system.debug('Body:'+resp.getBody());
        AccountDataWrapper resWrapper = (AccountDataWrapper)JSON.deserialize(resp.getBody(),AccountDataWrapper.class);
        
        List<Account> newAccounts = new List<Account>();
        for(AccountDataWrapper.Records eachRec :resWrapper.records){
            Account acc = new Account();
            acc.ExternalAccId__c=eachRec.Id;
            acc.Name = eachRec.Name;
            acc.OwnerId=eachRec.OwnerId;
            acc.ParentId = eachRec.ParentId;
            acc.Zone__c =eachRec.Zone__c;
            acc.Phone =eachRec.Phone;
            acc.Fax =eachRec.Fax ;
            acc.Website =eachRec.Website;
            acc.Type =eachRec.Type;
            acc.Industry =eachRec.Industry;
            acc.Description =eachRec.Description;
            acc.NumberOfEmployees =eachRec.NumberOfEmployees;
            acc.AnnualRevenue =eachRec.AnnualRevenue;
           
//acc.BillingAddress =eachRec.BillingAddress;
            //acc.ShippingAddress =eachRec.ShippingAddress;
            //acc.CreatedById =eachRec.CreatedById;
            //acc.LastModifiedById  =eachRec.LastModifiedById;
            newAccounts.add(acc);
        }
        
        upsert  newAccounts;
      

}
     global void finish(Database.BatchableContext BC){    
    }
}
Thanks in advance
If i create project in salesforce, it should get create in jira 

global with sharing class Jiraproject {

global static void createproject(string Name) {
       
       JSONGenerator gen = JSON.createGenerator(true);

        gen.writeStartObject();
        gen.writeStringField('Name', Name);
        //gen.writeStringField('Id',Id);
        //gen.writeStringField('status__c',status__c);
        gen.writeEndObject();   
    String jsonString = gen.getAsString();
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('url');
request.setMethod('POST');

String username = 'kh@abc.com ';
String password = ' PcuTBIDoQ96784';
       Blob headerValue = Blob.valueOf(username + ':' + password);
    String authorizationHeader = 'Basic ' +
     EncodingUtil.base64Encode(headerValue);
     request.setHeader('Authorization', authorizationHeader);

request.setHeader('Content-Type','application/json;charset=UTF-8');
 // Set the body as a JSON object
 request.setBody (jsonString);

HttpResponse response = http.send(request);

// If the request is successful, parse the JSON response.
if(response.getStatusCode() != 201) {
    System.debug('The status code returned was not expected: ' + response.getStatusCode() + ' ' + response.getStatus());
} else {
    System.debug(response.getBody());
}
    
}
 
}
 can anyone guideme? Thanks in advance
I got JSON response through postman.I am not sure what to be in salesforce rest apex -post method.

I referred this following code
Http http = new Http();
HttpRequest request = new HttpRequest(); request.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals');
request.setMethod('POST');
request.setHeader('Content-Type', 'application/json;charset=UTF-8'); // Set the body as a JSON object request.setBody('{"name":"mighty moose"}');
HttpResponse response = http.send(request);
// Parse the JSON response if(response.getStatusCode() != 201) { System.debug('The status code returned was not expected: ' + response.getStatusCode() + ' ' + response.getStatus()); }
else { System.debug(response.getBody()); }

I got error as
Missing return statement required return type: String

Can anyone guide me?Thanks in Advance
global class LeadInfoParser {
    global String LastName{get;set;}
    global String FirstName{get;set;}
    global String Company{get;set;}
    global String email{get;set;}
    global String Phone{get;set;}
    global String LeadStatus{get;set;}    

}
 @RestResource(urlMapping='/LeadService/*')
global without sharing class LeadService {
    @HttpPost
    global static String createLead(LeadInfoParser leadrec){
        Lead leadObj = new Lead();
        leadObj.FirstName =leadrec.FirstName;
        leadObj.LastName=leadrec.LastName; 
        leadObj.Phone=leadrec.Phone;
        leadObj.email=leadrec.email; 
        leadObj.Company = leadrec.Company;
        leadObj.Status = leadrec.LeadStatus;             
      
        Database.saveResult saveResult = database.insert(leadObj,false);
        if(saveResult.isSuccess()){
            System.debug('Record Id:'+saveResult.getId());
        }
        else{
            System.debug('saveResult:'+saveResult.getErrors());
        }
        //Response
        JSONGenerator gen=JSON.createGenerator(true);     
        gen.writeStartObject();
        gen.writeStringField('message','Lead record is created Successfully');
        gen.writeEndObject();     
        String responseString= gen.getAsString();
        return responseString;
    }


Thanks in Advance
I am filtering out reports in xaxis by created date on weekly basis. its segregating it by week with date(1/7/2022-7/7/2022) .can we modify that in to week 1?
I have two profiles,in profile 1 user should have read access to account and opportunity , only owner should  edit the record they own.

In profile 2 account and opportunity should be private.how to achiev this?

Thanks in advance
All users have create,read,edit,delete access. I need to modify it by providing  read access alone  to all users. Only record owner should have edit access.How to achieve it?

Thanks in advance
i tried in process builder and flows but its not updating instantly lead status field .
condition used:
Emailbouncedreason isnull =false
Leadstatus=disqualified
when i edit the record that time only it updating lead status.
class:
public class EmailToHR {         
    //@InvocableMethod
    public static list<Candiate__c> Candidates(){
        list<Candiate__c> CanList = new list<Candiate__c>();
        list<String> IntStatus = new string[] {'L1 Selected','Selected'};
            list<Candiate__c> SelectedCandidates =  [Select First_name__c, Interview_Status__c 
                                                     FROM Candiate__c
                                                     WHERE Interview_Status__c IN :IntStatus ];  
        for(Candiate__c can : SelectedCandidates){
            CanList.add(can);
        }
        return CanList;
    }  
    @InvocableMethod
    Public static void HREmail(){
        //list<IndividualEmail__c> em = IndividualEmail__c.getall().values();
        EmailTemplate tempId = [Select id, name, body,HTMLvalue From EmailTemplate Where name='EmailtoHR'];
        String emailBody = tempId.HTMLValue;
        integer NoCandidates = Candidates().size();
        emailbody = emailbody.replace('Selected_Candidates', string.valueof(NoCandidates));
        IndividualEmail__c InEmail = IndividualEmail__c.getInstance('VenolinTalent Acquisition Group');
        
        //IndividualEmail__c InEmail = IndividualEmail__c.getvalues('VenolinTalent Acquisition Group');
        system.debug(InEmail);
        string hrEmail = string.valueOf(InEmail.Email__c);
        //string hrEmail = InEmail.Email__c;
        if (hrEmail != Null){
            String[] toAddresses = new String[] {hrEmail,'hr@venolin.com'};
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            mail.setTemplateID(tempId.id);
            mail.setToAddresses(toAddresses);
            mail.setSubject('selected candidates');
            mail.setPlainTextBody(NoCandidates + 'Candidates are selected');
            mail.setHtmlBody(emailbody);
            messaging.sendEmail(new Messaging.SingleEmailMessage [] {mail});           
        }
    }
}

testclass:
@isTest
public class TestEmailToHR {
    @isTest public static void testMail (){
         IndividualEmail__c cust = new IndividualEmail__c();
         cust.Email__c = 'sacgaze@gmail.com';
         cust.Name = 'VenolinTalent Acquisition Group';
         insert cust;
        Position__c pos2 = new Position__c();
            pos2.TechnicalSkils__c = 'Salesforce';
            pos2.YearsOfExperience__c = '1 Year';
            pos2.NumberOfPositions__c = 2;
            pos2.SkillSet__c = 'Sales Cloud';
            pos2.SubSetOfSkills__c = 'Admin';
            pos2.Role__c = 'Developer';
            //pos1.RelatedCandidate__c = canp.id;
            insert pos2;
       list<Candiate__c> Candidates = new list<Candiate__c>();
        for (integer i=0; i<5; i++){
            Candidates.add(new Candiate__c(First_Name__c = 'Nikhil',
                                           Last_Name__c = 'Rao',
                                           Mobile_No__c = '98773339402',
                                           Current_Employer__c = 'TCS',
                                           Current_Employment__c = 'permanent',
                                           CTC__c = 30000,    
                                           Position_Object__c = pos2.id,
                                           Status__c = 'Scheduled',
                                           Email_ID__c = 'test@gmail.com',
                                           Ready_for_Contract__c = 'Yes',
                                           Communication__c = '8',
                                           Hands_on_JD__c = '7',
                                           Knowledge__c     = '7',
                                           Expected_CTC__c = 40000,
                                           Interview_Status__c = 'L1 Selected'));
        }
        insert Candidates;
    }
    @isTest 
    static void testEmail(){
        Test.startTest();
        IndividualEmail__c cust = new IndividualEmail__c();
         cust.Email__c = 'sacgaze@gmail.com';
         cust.Name = 'VenolinTalent Acquisition Group';
         insert cust;
        EmailToHR.HREmail();
        Test.stopTest();
    }
}

thanks in advance
I included process builder .but when i try to deploy its email templates are not included . how to include email templates in unmanaged package.

Thanks in advance.
I queried Tasks
SELECT accountid FROM Task WHERE What.Type = 'Account 'AND CreatedDate = LAST_N_MONTHS:24
I queried Account and Opportunity
SELECT Id, Name FROM account WHERE Rating = 'Prospect 'AND Id NOT IN (SELECT accountid FROM Opportunity WHERE CreatedDate = LAST_N_MONTHS:24) 
how to connect this withmy Account and opportunity.

Thanksin Advance
I got error  like First error: SendEmail failed. First exception on row 0; first error: INVALID_ID_FIELD, ID is invalid or you do not have access to the record.: [toAddresses, rid.Owner.Email]

public class AccountRatingBatchClass implements  Database.Batchable<sObject> {
    public List<Account> start(Database.BatchableContext bc){
        Integer year = Date.today().year() - 1;
        
       List<Account> aq = [SELECT Id,Rating,CreatedDate FROM Account 
                        WHERE CALENDAR_YEAR(CreatedDate) =:year AND CreatedDate < LAST_N_DAYS:365 AND Rating = 'Client' AND OpportunityCount__c=0];
        return aq;
    }
    public void execute(Database.BatchableContext bc,List<Account> accList){
        for(Account acc : accList){
            acc.Rating='Prospect';
        }
        
        
        List<Messaging.SingleEmailMessage> atm = new List<Messaging.SingleEmailMessage>();  
            EmailTemplate et=[Select id from EmailTemplate where Name='AccountProspectGetOpp'];
                for(Account al : accList){
        
                    Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();       
                        List<AccountTeamMember> recips = new List<AccountTeamMember>(
                                [SELECT UserId,User.isActive,User.Email FROM AccountTeamMember 
                                    WHERE AccountId =: al.Id AND User.isActive=true]);
            
            for(AccountTeamMember rid : recips){
                mail.settoAddresses(new string[]{'rid.Owner.Email'});
                mail.setTargetObjectId(rid.UserId);
                mail.setSenderDisplayName('Salesforce System');
                mail.setUseSignature(false);
                mail.setBccSender(false);
                mail.setSaveAsActivity(false);
                mail.setTemplateId(et.Id);
            }
                
        atm.add(mail);
    } 
        for(Account acl : accList){
        
                    Messaging.SingleEmailMessage mails = new Messaging.SingleEmailMessage();       
                        List<Account> recip = new List<Account>(
                                [SELECT ownerId,owner.Email FROM Account WHERE Id =: acl.Id]);
            
            for(Account rrid : recip){
                mails.settoAddresses(new string[]{'rid.Owner.Email'});
                mails.setTargetObjectId(rrid.ownerid);
                mails.setSenderDisplayName('Salesforce System');
                mails.setUseSignature(false);
                mails.setBccSender(false);
                mails.setSaveAsActivity(false);
                mails.setTemplateId(et.Id);
            }
                
        atm.add(mails);
            
    } 
     update accList;  
        System.debug(accList);
    Messaging.sendEmail(atm);
    }
public void finish(Database.BatchableContext bc){
     
}
}

thanks in advance
User-added image
 
Task object have Master Detail Relationship with Phase , project objects
Project object  have Lookup relationship with program object .
API name for program lookup field in project object is inov8__Program__c
how to fetch program object values in this soql?

select name,inov8__Phase__r.inov8__Project__r.Name from inov8__PMT_Task__c 

Thanks in Advance.
I created subcontact__c object  and created lookup relationship  with contact .child relationship Name -subcontacts

1.I tried to query child to parent  
select Name, Account.Name from Contact  - got response
2.when i trield to query grand child to parent  getting error 
select Name, Contact.Account.Name from subcontact__c - got error

Can you clarify me, why i didnt get response?
Thanks in Advance. 


Task is the child of phase
when i try to query from child to parent,grand parent great grand parent.(App which i am trying is PMT)


i am getting error as
select Name,inov8__PMT_Phase__r.inov8__PMT_Project__r.name
            ^
ERROR at Row:1:Column:13
Didn't understand relationship 'inov8__PMT_Phase__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
select Name,inov8__PMT_Phase__r.Name from inov8__PMT_Task__c

Thanks in advance
I am able to fetch the standard fields in rest batch Apex. but unable to fetch the custom fields .

Thanks in advance
I got error as 'variable doesnot exist' for my fields .(Highlighted fields for which i am getting error)
This is my code:
global class RecruitmentCalloutBatch implements Database.Batchable<sObject>,Database.AllowsCallouts {
     
     global Database.QueryLocator start(Database.BatchableContext BC) {
         String query = 'Select Id,Name,OwnerId,ParentId,Zone__c,ExternalAccId__c,Phone,Fax,Website,Type,Industry,Description,NumberOfEmployees,AnnualRevenue from Account';
         return Database.getQueryLocator(query);
 }

     global void execute(Database.BatchableContext BC, List<Account> Accrecords) { 
           
         HttpRequest req = new HttpRequest();
        String accquery='select+Id,Name,OwnerId,ParentId,Zone__c,ExternalAccId__c,Phone,Fax,Website,Type,Industry,Description,NumberOfEmployees,AnnualRevenue+from+Account';
        req.setEndpoint('callout:Recruitmen/services/data/v49.0/query/?q='+accquery);
        req.setMethod('GET');
        Http http = new Http();
        HTTPResponse resp = http.send(req);
        //This response will have all the data records in json structure
        system.debug('Body:'+resp.getBody());
        AccountDataWrapper resWrapper = (AccountDataWrapper)JSON.deserialize(resp.getBody(),AccountDataWrapper.class);
        
        List<Account> newAccounts = new List<Account>();
        for(AccountDataWrapper.Records eachRec :resWrapper.records){
            Account acc = new Account();
            acc.ExternalAccId__c=eachRec.Id;
            acc.Name = eachRec.Name;
            acc.OwnerId=eachRec.OwnerId;
            acc.ParentId = eachRec.ParentId;
            acc.Zone__c =eachRec.Zone__c;
            acc.Phone =eachRec.Phone;
            acc.Fax =eachRec.Fax ;
            acc.Website =eachRec.Website;
            acc.Type =eachRec.Type;
            acc.Industry =eachRec.Industry;
            acc.Description =eachRec.Description;
            acc.NumberOfEmployees =eachRec.NumberOfEmployees;
            acc.AnnualRevenue =eachRec.AnnualRevenue;
           
//acc.BillingAddress =eachRec.BillingAddress;
            //acc.ShippingAddress =eachRec.ShippingAddress;
            //acc.CreatedById =eachRec.CreatedById;
            //acc.LastModifiedById  =eachRec.LastModifiedById;
            newAccounts.add(acc);
        }
        
        upsert  newAccounts;
      

}
     global void finish(Database.BatchableContext BC){    
    }
}
Thanks in advance
global class LeadInfoParser {
    global String LastName{get;set;}
    global String FirstName{get;set;}
    global String Company{get;set;}
    global String email{get;set;}
    global String Phone{get;set;}
    global String LeadStatus{get;set;}    

}
 @RestResource(urlMapping='/LeadService/*')
global without sharing class LeadService {
    @HttpPost
    global static String createLead(LeadInfoParser leadrec){
        Lead leadObj = new Lead();
        leadObj.FirstName =leadrec.FirstName;
        leadObj.LastName=leadrec.LastName; 
        leadObj.Phone=leadrec.Phone;
        leadObj.email=leadrec.email; 
        leadObj.Company = leadrec.Company;
        leadObj.Status = leadrec.LeadStatus;             
      
        Database.saveResult saveResult = database.insert(leadObj,false);
        if(saveResult.isSuccess()){
            System.debug('Record Id:'+saveResult.getId());
        }
        else{
            System.debug('saveResult:'+saveResult.getErrors());
        }
        //Response
        JSONGenerator gen=JSON.createGenerator(true);     
        gen.writeStartObject();
        gen.writeStringField('message','Lead record is created Successfully');
        gen.writeEndObject();     
        String responseString= gen.getAsString();
        return responseString;
    }


Thanks in Advance
I have two profiles,in profile 1 user should have read access to account and opportunity , only owner should  edit the record they own.

In profile 2 account and opportunity should be private.how to achiev this?

Thanks in advance
I couldnt see debug statements aswell. its not showing error got 100% coverage. when i use database.execute batch totalbatch processed it shows 1 and zero failures. only after schedule it shows  total batch zero in apex jobs.can anyone guide me to resolve this issue?

global class UpdateAccountRating implements Database.Batchable<sObject> {
   
 global  Database.QueryLocator start(Database.BatchableContext bc) {
     set<string> strlist = new set<string>{'workInprogress','Delivered','ClosedWon'};
      string query='select id, stageName,AccountId, Account.Rating from opportunity where stageName IN :strlist AND AccountId !=Null';
     system.debug('query=='+query);
     return Database.getQueryLocator(query); 
    }
     global Void execute(Database.BatchableContext bc, List<opportunity> Scope){
      
        for(opportunity o :Scope){
            o.Account.Rating='client';  
          system.debug('Rating'+o.Account.Rating);
           
        }
         update Scope;}
         global void finish(Database.BatchableContext bc){
       
        AsyncApexJob job = [SELECT Id, Status,NumberOfErrors,JobItemsProcessed,TotalJobItems, CreatedBy.Email 
                            FROM AsyncApexJob
                            WHERE Id = :bc.getJobId()];  
    }   
     } 

testclass
@isTest
public class UpdateAccountRatingTest {
    @isTest
    public static void unit_test(){
      
        Account acc =new Account();
        acc.Name = 'test';
        acc.Rating='prospect';
        insert acc;
        
        
        Opportunity opp = new opportunity();
        opp.Name = 'test opp';
        opp.Accountid = acc.Id;
        opp.stageName = 'workInprogress';
        opp.CloseDate = system.today()+5;
        insert opp;
         
       
        
        Test.startTest();
      
        UpdateAccountRating uar  = new UpdateAccountRating();
        Database.executeBatch(uar);
      String sch = '0 0 0 1 * ? *';
      string JobID = system.schedule('BatchJob',sch, new UpdateAccountRatingSchedular());
        Test.stopTest();
       

 }
    }
schedular
global class UpdateAccountRatingSchedular implements Schedulable {
global void execute(SchedulableContext sc){
        UpdateAccountRating uar = new UpdateAccountRating();
        database.executebatch(uar);
    }
}


Thanks in advance
global class UpdateAccountRating implements Database.Batchable<sObject> {
   
 global  Database.QueryLocator start(Database.BatchableContext bc) {
     set<string> strlist = new set<string>{'workInprogress','Delivered','ClosedWon'};
      string query='select id, stageName,AccountId, Account.Rating from opportunity where stageName IN :strlist AND AccountId !=Null';
     system.debug('query=='+query);
     return Database.getQueryLocator(query); 
    }
     global Void execute(Database.BatchableContext bc, List<opportunity> Scope){
      
        for(opportunity o :Scope){
            o.Account.Rating='client';  
          system.debug('Rating'+o.Account.Rating);
           
        }
         update Scope;}
         global void finish(Database.BatchableContext bc){
       
        AsyncApexJob job = [SELECT Id, Status,NumberOfErrors,JobItemsProcessed,TotalJobItems, CreatedBy.Email 
                            FROM AsyncApexJob
                            WHERE Id = :bc.getJobId()];  
    }   
     }

testclass
@isTest
public class UpdateAccountRatingTest {
    @isTest
    public static void unit_test(){
      
        Account acc =new Account();
        acc.Name = 'test';
        acc.Rating='prospect';
        insert acc;
        
        
        Opportunity opp = new opportunity();
        opp.Name = 'test opp';
        opp.Accountid = acc.Id;
        opp.stageName = 'workInprogress';
        opp.CloseDate = system.today()+5;
        insert opp;
         
       
        
        Test.startTest();
      
        UpdateAccountRating uar  = new UpdateAccountRating();
        Database.executeBatch(uar);
      String sch = '0 0 0 1 * ? *';
      string JobID = system.schedule('BatchJob',sch, new UpdateAccountRatingSchedular());
        Test.stopTest();
       

 }
    }
schedular
global class UpdateAccountRatingSchedular implements Schedulable {
global void execute(SchedulableContext sc){
        UpdateAccountRating uar = new UpdateAccountRating();
        database.executebatch(uar);
    }
}

User-added image
Batch
global class UpdateAccountRating implements Database.Batchable<sObject>, Database.Stateful {
    global Integer recordsProcessed = 0;
 global  Database.QueryLocator start(Database.BatchableContext bc) {
      string query='select id, stageName,AccountId, Account.Rating from opportunity where stageName IN (\'workInprogress,Delivered,closedwon\') AND AccountId !=Null';
     return Database.getQueryLocator(query); 
    }
     global Void execute(Database.BatchableContext bc, List<opportunity> Scope){
      
        for(opportunity o :Scope){
            o.Account.Rating='client';  
          system.debug('Rating'+o.Account.Rating);
            recordsProcessed = recordsProcessed + 1;
        }
         update Scope;}
         global void finish(Database.BatchableContext bc){
        System.debug(recordsProcessed + 'records processed. Shazam!');
        AsyncApexJob job = [SELECT Id, Status,NumberOfErrors,JobItemsProcessed,TotalJobItems, CreatedBy.Email 
                            FROM AsyncApexJob
                            WHERE Id = :bc.getJobId()];  
    }   
     }

test class
@isTest
public class UpdateAccountRatingTest {
    @isTest
    public static void unit_test(){
       //insert All mandatory fields
        Account acc =new Account();
        acc.Name = 'test';
        acc.Rating='prospect';
        insert acc;
        
        //insert All mandatory fields
        Opportunity opp = new opportunity();
        opp.Name = 'test opp';
        opp.Account.Rating='prospect'; 
        opp.Accountid = acc.Id;
        opp.stageName = 'workInprogress';
        opp.CloseDate = system.today()+5;
        insert opp;
         
       
        
        Test.startTest();
      
        UpdateAccountRating uar  = new UpdateAccountRating();
        Database.executeBatch(uar);
      String sch = '0 0 0 1 * ? *';
      string JobID = system.schedule('BatchJob',sch, new UpdateAccountRatingSchedular());
        Test.stopTest();
       

 }
    }

thanks in advance