• harsha vardhan vasa 9
  • NEWBIE
  • 40 Points
  • Member since 2018

  • Chatter
    Feed
  • 1
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 13
    Questions
  • 13
    Replies
Hello,

I have below settings:

objectCustom__c
   picklist_custom__c
   A
   B
   C

    picklist_custom1__c
    X
    Y

I want to implement Validation rule like below:

Validation Rule 1:

If picklist_custom__c  = C,
   then only User is able to choose picklist_custom1__c = X 

Validation Rule 2:
If  picklist_custom1__c = X,
 Then dont allow user to modify it

What should be validation rule code.

Thank you for sugestion.
Q) need to update parent record when child is updated. and need to update child when parent is updated. field city__C.
i have implemented after update which works fine in 2 individual scenarios. but when i combine the code im getting error.
code snippet:
trigger Child_update on Account (after update) {
    set<id> accid = new set<id>();
    list<account> acclist1 = new list<account>();
    list<account> upd = new list<account>();
     boolean vardhan;
    list<account> accid1 = new list<account>();
    set<id> acc =new set<id>();
    boolean harsha;
    for(account a:trigger.new){
        accid1 =[select id,name from account where id=:a.id and parentid =null ];
        if(accid1.size()>0){
            harsha =true;
        }
        else harsha=false;
        
        for(Account ab:accid1){
            acc.add(ab.id);
        }
    }
    if(harsha==true){
    list<account> acclist= [select id ,name,city__C,(select id,city__C from ChildAccounts) from account where id in :acc];
    list<account> updatelst = new list<account>();
    system.debug('list of records with child'+acclist);
    
        for(Account a :acclist){
            for(account abc:a.childaccounts){
                abc.City__c=a.City__c;
                updatelst.add(abc);
                system.debug('ayya vachindhi code');
            }
        }
        
        if(!updatelst.isEmpty()){
            update updatelst; 
        }   
 }

//second piece of code:
 if(harsha==false){
    for(account a:trigger.new){
      account[] acclst=[select id,name,parentid,city__c from account where id=:a.id and parentid !=null];
        for(account c:acclst){
        accid.add(c.ParentId);
        }
    }
    acclist1 =[select id,name,city__C from account where id =:accid];
   
    for(account r:trigger.new){
    for(account a:acclist1){
        system.debug('code vachindhi');
        a.City__c=r.city__C;
        upd.add(a);
    }
        }
        if(!upd.isempty()){
update upd;
        }
    }





help me if anyone had similar requirement
Hi all,
i have one requirement,i need to check the feasibility:
 is it possible to deactivate users in bulk through vf page.when selected multiple users to deactivate ,that user opportunities also transferred to his manager. is this possible.
can anyone had sample code? 
please help 
hi guys,
i have implemented vf to get the userterritory detatils for the entered username in search box.i am able to get the results from the soql query but not able to display on vf screen,
PFB code and let know where i went wrong.
VF Page:
<apex:page controller="Apexcontroller" >
    <apex:form >
        <apex:pageBlock >
            <apex:pageMessages id="showmsg"></apex:pageMessages>
            <apex:pageBlockSection >
                <apex:inputText value="{!searchstring}" label=" enter username here" />
                <apex:commandButton value="Search" action="{!search}" reRender="accpg,showmsg" />
            </apex:pageBlockSection>
            <apex:pageBlockTable value="{!usrter}" var="a" id="accpg" rendered="{!usrter.size!= 0}">
            <!--    <apex:column value="{!a.id}" /> -->
                <apex:column headerValue="user">
                   <apex:inputfield required="{false}" value="{!a.userid}" />
                </apex:column>
                <apex:column headerValue="Territory">
                   <apex:inputfield required="{false}" value="{!a.territoryid}" />
                </apex:column>
          <!--      <apex:column value="{!a.territoryid}" /> -->
            </apex:pageBlockTable>
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>  
</apex:page>

Controller:
public class Apexcontroller {
    public string searchstring{get;set;}
    public list<userterritory> usrter{get;set;} 
    public list<user> usrlist = new list<user>();
    public Apexcontroller(){
        usrter =new list<userterritory>();
    }
    public void search(){
        system.debug('value of searchstring entered is'+searchstring); 
        user[] usr =[select id from user where username =:searchstring];
        for(user u:usr){
            usrter=[select id,userid,territoryid,isactive from userterritory where userid =:u.id];
            system.debug('userterritory list is'+usrter);
            if(usrter.size() ==0){
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,'No matching territories found for the entered username'));
            }
        }
    }
    public void save(){
    }
    
}
HI guys,
i need to assign  territory on one user to another user. how can this be achieved in coding.please let know the solution and code if present or any references will be helpful.
Regards,
Harsha.
save button and when clicked that record with updated value should saved against that record.
when user updating the lookup on VF page it should get saved to record.
need save functionality.
Below code:
VF page:
<apex:page Controller="CustAccount" >
    <apex:form >
        <apex:pageBlock >
            <apex:pageMessages id="showmsg"></apex:pageMessages>
            <apex:pageBlockSection>
                <apex:inputText value="{!searchstring}" label=" enter username here" />
                <apex:commandButton value="Search" action="{!search}" reRender="accpg,showmsg" />
            </apex:pageBlockSection>
            <apex:pageBlockTable value="{!acc}" var="a" id="accpg" rendered="{!acc.size != 0}">
                <apex:column value="{!a.name}"/>
                <apex:column value="{!a.stagename}"/>
                <apex:column value="{!a.amount}" />
                <apex:column title="UserName" headerValue="Username">
                <apex:inputfield value="{!a.UserName__c}" /> 
               </apex:column>
                <apex:column>
                <apex:inputfield value="{!a.ownerid}" />
                    </apex:column>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Controller:
public with sharing class CustAccount {
    public string searchstring {get;set;}
    public List<opportunity> acc {get;set;}
    public custaccount() {
    }
    public void search(){
        if(searchstring !=null || searchstring!= ''){
            system.debug(searchstring );
            /*  acc= [SELECT Name, StageName, CloseDate, Amount, Owner.Name, Owner.Username,username__C
FROM Opportunity where Owner.username like : ('%' +searchstring + '%')];  */
            acc= [SELECT Name, StageName, CloseDate, Amount, Owner.Name, Owner.Username,username__c
                  FROM Opportunity where Owner.username like : ('%' +searchstring + '%')]; 
            system.debug('value os acc is '+acc);
            system.debug(acc.size());
            if(acc.size() ==0){
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,'No matching opportunities found for the entered value'));
            }
        }
    }
}
pls help me guys.
Regards,
harsha
hi guys,
i want to reassign all the opportunities of the user to other user when deactivated. please let know the solution towards it. 
 
Error:
This page has an error. You might just need to refresh it. Action failed: c:usercmp$controller$doInit [action.setcallback is not a function] Failing descriptor: {c:usercmp$controller$doInit}
Code :
Apexclass:
public with sharing class userdetails {
    @AuraEnabled
    public static user fetchuser(){
        user user1=new user();
        user1=[select id,username,firstname,lastname,email from user where id =:  userinfo.getUserId()];
        return user1;
    }
}

Component:
<aura:component controller="userdetails" >
    <aura:handler name="init" value="this" action="{!c.doInit}" />
    <aura:attribute name="usercmp"  type="user"/>
    <b> User details are below mentioned</b>
    <p> {!v.usercmp.email}</p>
    <p> {!v.usercmp.firstname}</p>
    <p> {!v.usercmp.lastname}</p>
    <p> {!v.usercmp.username}</p>
</aura:component>

Controller:
({
    doInit : function(component, event, helper) {
        var action = component.get("c.fetchuser");
        console.log("vachindhi");
        action.setcallback(this,function(response){
            var state = response.getstate();
            console.log(""+state);
            if(state==="SUCCESS"){
                 var storeresponse=response.getreturnvalue();
                component.set("v.usercmp",storeresponse);
            }
        });
        $A.enqueueAction(action);
    }
})
Lightining app to preview the out put:
<aura:application  extends="force:slds">
    <c:usercmp />
</aura:application>

please help where i went wrong.
Hi guys,
Need help 
how can we display account hirearchy in the related list .
when parent account is linked to multi child accounts. how to display them in the related list. 
we sould not need to click on the view hirearchy to see the hiearchy.
any suggestions please.
Regards,
harsha Vardhan
 
Hi Guys, need Test class for the below Code  Snippet.please help :

trigger AccountContractTrigger on AccountContract__c (after insert, after delete) {
    List<AccountContract__c> targetList;
    if(Trigger.isInsert) {
        targetList = Trigger.new;
    } else if(Trigger.isDelete) {
        targetList = Trigger.old;
    }
    Set<Id> parentIds = new Set<Id>();
    for(AccountContract__c rec: targetList) {
        parentIds.add(rec.Contract__c);
    }
    List<ContractSheet__c> parentList = [SELECT Id, ContractPartner__c, (SELECT Account__r.Name FROM AccountChild__r) FROM ContractSheet__c WHERE Id IN: parentIds];
    system.debug('names is'+parentList);
    for(ContractSheet__c parent : parentList) {
        String names = '';
        for(AccountContract__c nameSource: parent.AccountChild__r) {
            names += nameSource.Account__r.Name + ', ';
        }
        names = names.removeEnd(', ');
        parent.ContractPartner__c = names;
        system.debug('names is'+parent.ContractPartner__c);
    }
    update parentList;
}

 
Hi guys ,
need to write a class for the test class attached. please help me asap:
    @istest
    static void insertTest01() {
        //契約
        ContractSheet__c contract = new ContractSheet__c();
        contract.Name = 'Contract1';
        insert contract;
        //企業
        Account acc1 = new Account();
        acc1.Name = 'Acc1';
        Account acc2 = new Account();
        acc2.Name = 'Acc2';
        insert new List<Account>{acc1, acc2};
        //契約締結先
        AccountContract__c accCon1 = new AccountContract__c();
        accCon1.Contract__c = contract.Id;
        accCon1.Account__c = acc1.Id;
        AccountContract__c accCon2 = new AccountContract__c();
        accCon2.Contract__c = contract.Id;
        accCon2.Account__c = acc2.Id;

        Test.startTest();
        insert new List<AccountContract__c>{accCon1, accCon2};
        Test.stopTest();

        contract = [SELECT ContractPartner__c FROM ContractSheet__c WHERE Id =: contract.Id];
        system.assertEquals(acc1.Name + ', ' + acc2.Name, contract.ContractPartner__c);
    }

Regards,
Vasa Harsha Vardhan.
Hi All,
i need to display the only half-size of the headervalue. example-- instead of "LabelName" as "Label".
is it possible to trim the headervalue.

<apex:column headerValue="{!$ObjectType.Product2.Fields.BModelNumber2__c.Label}"  styleClass="{!IF(vhlp.isParent,'parent_row', IF(vhlp.isChild,'child_row',''))}"

regards,
Vasa harsha Vardhan.
Helper Class:
public void setMaintenanceDateAfterUpdate(){
        list<Id> assetIds =new list<Id>();
        list<sls_Asset__c> assetList = new List<sls_Asset__c>();
        for(sls_Asset__c a:newList){
            if((trgOldMap.get(a.Id).sls_StartDate__c == null && trgNewMap.get(a.Id).sls_StartDate__c !=null)||
                (trgOldMap.get(a.Id).sls_StartDate__c <> trgNewMap.get(a.Id).sls_StartDate__c) ){
                  assetIds.add(a.Id);
               }      
        }
        if(!assetIds.isEmpty()){
            for(sls_Asset__c a : [select id,sls_startdate__c,sls_MaintenanceDate__c,sls_CheckDate__c,sls_OrderProduct__c,sls_OrderProduct__r.BProduct2__c,sls_OrderProduct__r.BProduct2__r.name,sls_OrderProduct__r.BProduct2__r.sls_InspectionPeriodMonths__c,sls_OrderProduct__r.BProduct2__r.sls_UsefulLifeMonths__c from sls_Asset__c where id =: assetIds]){
               integer inspect  = Integer.valueOf( a.sls_OrderProduct__r.BProduct2__r.sls_InspectionPeriodMonths__c);
                integer useful = Integer.valueOf(a.sls_OrderProduct__r.BProduct2__r.sls_UsefulLifeMonths__c);
                a.sls_MaintenanceDate__c = trgNewMap.get(a.Id).sls_StartDate__c.addmonths(inspect);
                a.sls_CheckDate__c = trgNewMap.get(a.Id).sls_StartDate__c.addmonths(useful);
                 assetList.add(a);

             }
        }
        if(!assetList.isEmpty()){
             system.debug('assetList:'+assetList);
            update assetList;
        }
           
    }

test Class:
static testMethod void setMaintenanceDateTest01(){
         BCMNTestDataUtil.loadBProfitStandard();
         User user = BCMNTestDataUtil.newUser(false);
         user.Department = '営業統括部';
         insert user;
         Account acc = BCMNTestDataUtil.newAccount('account01', '01234', true);
         Product2 product = BCMNTestDataUtil.newProduct2('Product1', 'PRODUCT1', 'AEDオプション', false);
         product.sls_InspectionPeriodMonths__c = 12; //点検月数
         product.sls_UsefulLifeMonths__c = 24;       //耐用月数
         insert product;
         PricebookEntry pbe = BCMNTestDataUtil.newStandardPricebookEntry(product, 20000, 10000, true);
         Opportunity opp = BCMNTestDataUtil.newOpportunity('opp01', user.Id, acc.Id, pbe.Pricebook2Id, false);
         opp.BSalesForm__c = '常駐警備';
         insert opp;
         BOrder__c order = BCMNTestDataUtil.newBOrder(opp.Id, true);
         BOrderProduct__c orderProduct =BCMNTestDataUtil.newBOrderProduct(order.Id, false);
         orderProduct.BProduct2__c = product.id;
         orderProduct.BUnitPrice__c = 20000;
         orderProduct.BQuantity__c = 2;
          insert orderProduct;
         Test.startTest();
         sls_Asset__c asset1 = new sls_Asset__c();
         asset1.sls_OrderProduct__c = orderProduct.Id;
         asset1.sls_Status__c = '保証書受領待ち';
         asset1.sls_StartDate__c = system.today();
         sls_Asset__c asset2 = new sls_Asset__c();
         asset2.sls_OrderProduct__c = orderProduct.Id;
         asset2.sls_Status__c = '保証書受領待ち';
         asset2.sls_StartDate__c = system.today();
         insert new List<sls_Asset__c>{asset1, asset2};
         Test.stopTest();
         //交換したレコードのステータスが更新されていること
         asset1 = [SELECT Id, sls_Status__c, sls_StartDate__c, sls_MaintenanceDate__c, sls_CheckDate__c FROM sls_Asset__c WHERE Id =: asset1.Id];
         system.assertEquals(asset1.sls_StartDate__c.addMonths(integer.valueOf(product.sls_InspectionPeriodMonths__c)), asset1.sls_MaintenanceDate__c);   //交換期限
         system.assertEquals(asset1.sls_StartDate__c.addMonths(integer.valueOf(product.sls_UsefulLifeMonths__c)), asset1.sls_CheckDate__c);         //点検期限
         asset2 = [SELECT Id, sls_Status__c, sls_StartDate__c, sls_MaintenanceDate__c, sls_CheckDate__c FROM sls_Asset__c WHERE Id =: asset2.Id];
         system.assertEquals(asset2.sls_StartDate__c.addMonths(integer.valueOf(product.sls_InspectionPeriodMonths__c)), asset2.sls_MaintenanceDate__c);
         system.assertEquals(asset2.sls_StartDate__c.addMonths(integer.valueOf(product.sls_UsefulLifeMonths__c)), asset2.sls_CheckDate__c);
     }

Error:
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, sls_AssetTrigger: execution of AfterInsert

caused by: System.NullPointerException: Argument cannot be null.
i need to inser contact record for every new account got created.
how can we achieve this and in how many ways we can achieve ?
please send me code snippiet also in programmatic approach.
could anyone help me on this.
How to write the batch apex progarm.

( Write a batch class to delete all the accounts where billing country equal to united states of America or US or USA handle the field records also in the same batch and return the batch class to delete failed records also. Once these US records are deleted )
Hello,

I have below settings:

objectCustom__c
   picklist_custom__c
   A
   B
   C

    picklist_custom1__c
    X
    Y

I want to implement Validation rule like below:

Validation Rule 1:

If picklist_custom__c  = C,
   then only User is able to choose picklist_custom1__c = X 

Validation Rule 2:
If  picklist_custom1__c = X,
 Then dont allow user to modify it

What should be validation rule code.

Thank you for sugestion.
hi guys,
i have implemented vf to get the userterritory detatils for the entered username in search box.i am able to get the results from the soql query but not able to display on vf screen,
PFB code and let know where i went wrong.
VF Page:
<apex:page controller="Apexcontroller" >
    <apex:form >
        <apex:pageBlock >
            <apex:pageMessages id="showmsg"></apex:pageMessages>
            <apex:pageBlockSection >
                <apex:inputText value="{!searchstring}" label=" enter username here" />
                <apex:commandButton value="Search" action="{!search}" reRender="accpg,showmsg" />
            </apex:pageBlockSection>
            <apex:pageBlockTable value="{!usrter}" var="a" id="accpg" rendered="{!usrter.size!= 0}">
            <!--    <apex:column value="{!a.id}" /> -->
                <apex:column headerValue="user">
                   <apex:inputfield required="{false}" value="{!a.userid}" />
                </apex:column>
                <apex:column headerValue="Territory">
                   <apex:inputfield required="{false}" value="{!a.territoryid}" />
                </apex:column>
          <!--      <apex:column value="{!a.territoryid}" /> -->
            </apex:pageBlockTable>
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>  
</apex:page>

Controller:
public class Apexcontroller {
    public string searchstring{get;set;}
    public list<userterritory> usrter{get;set;} 
    public list<user> usrlist = new list<user>();
    public Apexcontroller(){
        usrter =new list<userterritory>();
    }
    public void search(){
        system.debug('value of searchstring entered is'+searchstring); 
        user[] usr =[select id from user where username =:searchstring];
        for(user u:usr){
            usrter=[select id,userid,territoryid,isactive from userterritory where userid =:u.id];
            system.debug('userterritory list is'+usrter);
            if(usrter.size() ==0){
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,'No matching territories found for the entered username'));
            }
        }
    }
    public void save(){
    }
    
}
HI guys,
i need to assign  territory on one user to another user. how can this be achieved in coding.please let know the solution and code if present or any references will be helpful.
Regards,
Harsha.
hi guys,
i want to reassign all the opportunities of the user to other user when deactivated. please let know the solution towards it. 
 
Hi guys,
Need help 
how can we display account hirearchy in the related list .
when parent account is linked to multi child accounts. how to display them in the related list. 
we sould not need to click on the view hirearchy to see the hiearchy.
any suggestions please.
Regards,
harsha Vardhan
 
Hi guys ,
need to write a class for the test class attached. please help me asap:
    @istest
    static void insertTest01() {
        //契約
        ContractSheet__c contract = new ContractSheet__c();
        contract.Name = 'Contract1';
        insert contract;
        //企業
        Account acc1 = new Account();
        acc1.Name = 'Acc1';
        Account acc2 = new Account();
        acc2.Name = 'Acc2';
        insert new List<Account>{acc1, acc2};
        //契約締結先
        AccountContract__c accCon1 = new AccountContract__c();
        accCon1.Contract__c = contract.Id;
        accCon1.Account__c = acc1.Id;
        AccountContract__c accCon2 = new AccountContract__c();
        accCon2.Contract__c = contract.Id;
        accCon2.Account__c = acc2.Id;

        Test.startTest();
        insert new List<AccountContract__c>{accCon1, accCon2};
        Test.stopTest();

        contract = [SELECT ContractPartner__c FROM ContractSheet__c WHERE Id =: contract.Id];
        system.assertEquals(acc1.Name + ', ' + acc2.Name, contract.ContractPartner__c);
    }

Regards,
Vasa Harsha Vardhan.
Hi All,
i need to display the only half-size of the headervalue. example-- instead of "LabelName" as "Label".
is it possible to trim the headervalue.

<apex:column headerValue="{!$ObjectType.Product2.Fields.BModelNumber2__c.Label}"  styleClass="{!IF(vhlp.isParent,'parent_row', IF(vhlp.isChild,'child_row',''))}"

regards,
Vasa harsha Vardhan.
Helper Class:
public void setMaintenanceDateAfterUpdate(){
        list<Id> assetIds =new list<Id>();
        list<sls_Asset__c> assetList = new List<sls_Asset__c>();
        for(sls_Asset__c a:newList){
            if((trgOldMap.get(a.Id).sls_StartDate__c == null && trgNewMap.get(a.Id).sls_StartDate__c !=null)||
                (trgOldMap.get(a.Id).sls_StartDate__c <> trgNewMap.get(a.Id).sls_StartDate__c) ){
                  assetIds.add(a.Id);
               }      
        }
        if(!assetIds.isEmpty()){
            for(sls_Asset__c a : [select id,sls_startdate__c,sls_MaintenanceDate__c,sls_CheckDate__c,sls_OrderProduct__c,sls_OrderProduct__r.BProduct2__c,sls_OrderProduct__r.BProduct2__r.name,sls_OrderProduct__r.BProduct2__r.sls_InspectionPeriodMonths__c,sls_OrderProduct__r.BProduct2__r.sls_UsefulLifeMonths__c from sls_Asset__c where id =: assetIds]){
               integer inspect  = Integer.valueOf( a.sls_OrderProduct__r.BProduct2__r.sls_InspectionPeriodMonths__c);
                integer useful = Integer.valueOf(a.sls_OrderProduct__r.BProduct2__r.sls_UsefulLifeMonths__c);
                a.sls_MaintenanceDate__c = trgNewMap.get(a.Id).sls_StartDate__c.addmonths(inspect);
                a.sls_CheckDate__c = trgNewMap.get(a.Id).sls_StartDate__c.addmonths(useful);
                 assetList.add(a);

             }
        }
        if(!assetList.isEmpty()){
             system.debug('assetList:'+assetList);
            update assetList;
        }
           
    }

test Class:
static testMethod void setMaintenanceDateTest01(){
         BCMNTestDataUtil.loadBProfitStandard();
         User user = BCMNTestDataUtil.newUser(false);
         user.Department = '営業統括部';
         insert user;
         Account acc = BCMNTestDataUtil.newAccount('account01', '01234', true);
         Product2 product = BCMNTestDataUtil.newProduct2('Product1', 'PRODUCT1', 'AEDオプション', false);
         product.sls_InspectionPeriodMonths__c = 12; //点検月数
         product.sls_UsefulLifeMonths__c = 24;       //耐用月数
         insert product;
         PricebookEntry pbe = BCMNTestDataUtil.newStandardPricebookEntry(product, 20000, 10000, true);
         Opportunity opp = BCMNTestDataUtil.newOpportunity('opp01', user.Id, acc.Id, pbe.Pricebook2Id, false);
         opp.BSalesForm__c = '常駐警備';
         insert opp;
         BOrder__c order = BCMNTestDataUtil.newBOrder(opp.Id, true);
         BOrderProduct__c orderProduct =BCMNTestDataUtil.newBOrderProduct(order.Id, false);
         orderProduct.BProduct2__c = product.id;
         orderProduct.BUnitPrice__c = 20000;
         orderProduct.BQuantity__c = 2;
          insert orderProduct;
         Test.startTest();
         sls_Asset__c asset1 = new sls_Asset__c();
         asset1.sls_OrderProduct__c = orderProduct.Id;
         asset1.sls_Status__c = '保証書受領待ち';
         asset1.sls_StartDate__c = system.today();
         sls_Asset__c asset2 = new sls_Asset__c();
         asset2.sls_OrderProduct__c = orderProduct.Id;
         asset2.sls_Status__c = '保証書受領待ち';
         asset2.sls_StartDate__c = system.today();
         insert new List<sls_Asset__c>{asset1, asset2};
         Test.stopTest();
         //交換したレコードのステータスが更新されていること
         asset1 = [SELECT Id, sls_Status__c, sls_StartDate__c, sls_MaintenanceDate__c, sls_CheckDate__c FROM sls_Asset__c WHERE Id =: asset1.Id];
         system.assertEquals(asset1.sls_StartDate__c.addMonths(integer.valueOf(product.sls_InspectionPeriodMonths__c)), asset1.sls_MaintenanceDate__c);   //交換期限
         system.assertEquals(asset1.sls_StartDate__c.addMonths(integer.valueOf(product.sls_UsefulLifeMonths__c)), asset1.sls_CheckDate__c);         //点検期限
         asset2 = [SELECT Id, sls_Status__c, sls_StartDate__c, sls_MaintenanceDate__c, sls_CheckDate__c FROM sls_Asset__c WHERE Id =: asset2.Id];
         system.assertEquals(asset2.sls_StartDate__c.addMonths(integer.valueOf(product.sls_InspectionPeriodMonths__c)), asset2.sls_MaintenanceDate__c);
         system.assertEquals(asset2.sls_StartDate__c.addMonths(integer.valueOf(product.sls_UsefulLifeMonths__c)), asset2.sls_CheckDate__c);
     }

Error:
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, sls_AssetTrigger: execution of AfterInsert

caused by: System.NullPointerException: Argument cannot be null.
i need to inser contact record for every new account got created.
how can we achieve this and in how many ways we can achieve ?
please send me code snippiet also in programmatic approach.
could anyone help me on this.
i have created
1.AnimalLocator User-added image



2.AnimalLocatorMock
User-added image

3.AnimalLocatorTest

User-added image


error i am getting

User-added image

please help me