• Puja Dev 6
  • NEWBIE
  • 30 Points
  • Member since 2016

  • Chatter
    Feed
  • 1
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 9
    Replies
Hi,
I have following After Update Trigger... I have to write test class for same...
Please some one help me..?

trigger AccountChanged on Asset (after update) {

    List<Opportunity> OppList= new List<Opportunity>();
   
    for (Asset newAsset : Trigger.new) {

                                        // If account of equipment is changed..
        if ( newAsset.AccountId != Trigger.oldMap.get( newAsset.Id ).AccountId ){    
            
                                        //Create new Opportunity for Sales i.e. OEM Record Type...
            Opportunity newOpp1 = new Opportunity();
            
            Id oppRecordTypeId1 = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('OEM').getRecordTypeId();
            newOpp1.RecordTypeId = oppRecordTypeId1;
            
            
            newOpp1.Asset__c = newAsset.id;
            newOpp1.Name = 'New Sales Opportunity';
            newOpp1.AccountId = newAsset.AccountId;
            newOpp1.StageName = 'Qualification';
            newOpp1.CloseDate = system.today();
            

            OppList.add(newOpp1);
            
          
                                            //Create new Opportunity for Parts i.e. Parts Record Type...
            Opportunity newOpp2 = new Opportunity();
            
            Id oppRecordTypeId2 = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('Parts').getRecordTypeId();
            newOpp2.RecordTypeId = oppRecordTypeId2;
            
            
            newOpp2.Asset__c = newAsset.id;
            newOpp2.Name = 'New Parts Opportunity';
            newOpp2.AccountId = newAsset.AccountId;
            newOpp2.StageName = 'Qualification';
            newOpp2.CloseDate = system.today();
            

            OppList.add(newOpp2);
            
            If(OppList.Size()>0){
            Insert OppList;
            }
        }

    }
}
Hi All,

Please help me to bulkiefy the following :

 private void getAccountD(List<Account> acc){
         List<Account> account = new List<Account>();
         List<State_Master__c> SM = [SELECT TerritoryState__c,District__c,Town__c,Zone__c,RO__c,Territory_Code__c FROM State_Master__c];
         for(State_Master__c e : SM){
            for(Account g : acc){
                    if((e.TerritoryState__c == g.State_Name__c) && (e.District__c == g.District__c) && (e.Town__c == g.Town__c)){
                        system.debug('Update Acc');                        
                        g.Sales_Office_Text__c = e.Zone__c;
                        g.Sales_District_Text__c = e.Territory_Code__c;
                        g.Sales_Group_Text__c = e.RO__c;
                        account.add(g);
                    }     
            }
        }
        if(account.size() <= 0){
            for(Account g : acc){
                   g.Sales_Office_Text__c = '';
                   g.Sales_District_Text__c = '';
                   g.Sales_Group_Text__c = '';
                   account.add(g);            
            }
        }  
    }

It is working fine for individual record insert and update event.

But it gives
"AccountTrigger: System.LimitException: Apex CPU time limit exceeded" this error at the time of bulk data import.


Thanks in Advance,
Puja
Hello All,

<!-- NewAccount -->
<aura:component implements="force:appHostable" controller="AccountController">
    <aura:attribute name="newAccount" type="Account" default="{ 'sobjectType': 'Account', 'Name': '', }" access="public"/>
    <div >
        <center>
            <form>
                Name <force:inputField aura:id="Name" value="{!v.newAccount.Name}"/>
                Note <force:inputField aura:id="Note" value="{!v.newAccount.Description}"/>
                Categories<force:inputField aura:id="Categories" value="{!v.newAccount.Categories_del__c}"/>
                SubCategories<force:inputField aura:id="SubCategories" value="{!v.newAccount.Sub_Categories__c    }"/>
                Assign to<force:inputField aura:id="Assign To " value="{!v.newAccount.Assigned_To__c}"/>
                Billing Street <force:inputField aura:id="Street " value="{!v.newAccount.BillingStreet}"/>
                Billing City <force:inputField aura:id="City " value="{!v.newAccount.BillingCity}"/>
                Billing State <force:inputField aura:id="State " value="{!v.newAccount.BillingState}"/>
                Billing Country <force:inputField aura:id="Country " value="{!v.newAccount.BillingCountry}"/>
                Billing Postal Code<force:inputField aura:id="Postal Code " value="{!v.newAccount.BillingPostalCode}"/>
                <lightning:button label="Save" onclick="{!c.createAccount}" />
                
            </form>
        </center>
    </div>
</aura:component>



This is my sample code to save Account Record using Lightning Component. "Assign To"  is custom field of "User Lookup" ,  but it gives the following error. Check screen shot as well. I also enabled Lightning component checkbox.


"This page has an error. You might just need to refresh it.
Access Check Failed! AttributeSet.get(): attribute 'inContextOfRecordId' of component 'markup://c:NewAccount {3:0}' is not visible to 'markup://c:NewAccount {3:0}'.
Failing descriptor: {markup://c:NewAccount}"



User-added image
Hi
I have the following Lightning Component to save the record into Account Object.
It saves standard field (Acc Name, Description). But not Custom fields.

I want to add one picklist field and one lookup field on Component.

<!-- NewAccount -->
<aura:component implements="force:appHostable" controller="AccountController">
    <aura:attribute name="newAccount" type="Account" default="{ 'sobjectType': 'Account', 'Name': '', }"/>
    <div >
        <center>
            <form>
                <lightning:input aura:id="AccountName" name="New Account Name" label="Account Name"
                                 value="{!v.newAccount.Name}" required="true"/>
                <lightning:input aura:id="Description" name="New Account Name" label="Note"
                                 value="{!v.newAccount.Description}" required="true"/>
                <lightning:input aura:id="Categories" name="New Account Name" label="Categories"
                                 value="{!v.newAccount.Categories_del__c}" required="true"/>
                
                <lightning:select aura:id="myselection" value="{!v.selectValue}">
                    <aura:iteration items="{!v.options}" item="option">
                        <option value="{!option}">{!option}</option>
                    </aura:iteration>
                </lightning:select>
                
                <lightning:button label="Save" onclick="{!c.createAccount}" />
                
            </form>
        </center>
    </div>
</aura:component>


How to store Picklist and Lookup field ...?
Hi All,

I have formula field of text datatype. It used to captured QR code of each Campaign Member Record.
On VFPage it's working fine.
But on Render as PDF, it shows currepted image.

Following is the formula field :
QR Code :
IMAGE('https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl=MECARD://tjt--aresssbox.cs64.my.salesforce.com/'&Id ,'Scan QR code to open record in mobile.')
Hi,
Can we fire Workflow Rule or Process builder on change in formula field..?
Hi,

I want to copy value of "discounted box price(Currency field)" in to the standard field "Unit Price" of OrderLineItem Object.
I have tryed using Workflow rule. Its working but it can not fullfill my requirment. So,I want trigger to copy "discounted box price" to "Unit Price".
Please let me know the solution.

Thanks, in advanced.
Puja
Hi,

I have Junction object "Enrollment" (for Student Details and Test).
and I have Role Hierarchy, as folllowing : 
Admin ---- > Center Head --- > User

1. When I set OWD as "Private" for Student Details and Test then no any data is visible to "User". Not even self data.

2. When I set OWD as "Public Read/write" for Student Details and Test then all data is visible to "User". Data of admin too.

I want to show only User's data.

Please someone help to solve my issue...?


Regards,
​Puja
Hi All,

I have formula field of text datatype. It used to captured QR code of each Campaign Member Record.
On VFPage it's working fine.
But on Render as PDF, it shows currepted image.

Following is the formula field :
QR Code :
IMAGE('https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl=MECARD://tjt--aresssbox.cs64.my.salesforce.com/'&Id ,'Scan QR code to open record in mobile.')
Hi All,

Please help me to bulkiefy the following :

 private void getAccountD(List<Account> acc){
         List<Account> account = new List<Account>();
         List<State_Master__c> SM = [SELECT TerritoryState__c,District__c,Town__c,Zone__c,RO__c,Territory_Code__c FROM State_Master__c];
         for(State_Master__c e : SM){
            for(Account g : acc){
                    if((e.TerritoryState__c == g.State_Name__c) && (e.District__c == g.District__c) && (e.Town__c == g.Town__c)){
                        system.debug('Update Acc');                        
                        g.Sales_Office_Text__c = e.Zone__c;
                        g.Sales_District_Text__c = e.Territory_Code__c;
                        g.Sales_Group_Text__c = e.RO__c;
                        account.add(g);
                    }     
            }
        }
        if(account.size() <= 0){
            for(Account g : acc){
                   g.Sales_Office_Text__c = '';
                   g.Sales_District_Text__c = '';
                   g.Sales_Group_Text__c = '';
                   account.add(g);            
            }
        }  
    }

It is working fine for individual record insert and update event.

But it gives
"AccountTrigger: System.LimitException: Apex CPU time limit exceeded" this error at the time of bulk data import.


Thanks in Advance,
Puja
Hello All,

<!-- NewAccount -->
<aura:component implements="force:appHostable" controller="AccountController">
    <aura:attribute name="newAccount" type="Account" default="{ 'sobjectType': 'Account', 'Name': '', }" access="public"/>
    <div >
        <center>
            <form>
                Name <force:inputField aura:id="Name" value="{!v.newAccount.Name}"/>
                Note <force:inputField aura:id="Note" value="{!v.newAccount.Description}"/>
                Categories<force:inputField aura:id="Categories" value="{!v.newAccount.Categories_del__c}"/>
                SubCategories<force:inputField aura:id="SubCategories" value="{!v.newAccount.Sub_Categories__c    }"/>
                Assign to<force:inputField aura:id="Assign To " value="{!v.newAccount.Assigned_To__c}"/>
                Billing Street <force:inputField aura:id="Street " value="{!v.newAccount.BillingStreet}"/>
                Billing City <force:inputField aura:id="City " value="{!v.newAccount.BillingCity}"/>
                Billing State <force:inputField aura:id="State " value="{!v.newAccount.BillingState}"/>
                Billing Country <force:inputField aura:id="Country " value="{!v.newAccount.BillingCountry}"/>
                Billing Postal Code<force:inputField aura:id="Postal Code " value="{!v.newAccount.BillingPostalCode}"/>
                <lightning:button label="Save" onclick="{!c.createAccount}" />
                
            </form>
        </center>
    </div>
</aura:component>



This is my sample code to save Account Record using Lightning Component. "Assign To"  is custom field of "User Lookup" ,  but it gives the following error. Check screen shot as well. I also enabled Lightning component checkbox.


"This page has an error. You might just need to refresh it.
Access Check Failed! AttributeSet.get(): attribute 'inContextOfRecordId' of component 'markup://c:NewAccount {3:0}' is not visible to 'markup://c:NewAccount {3:0}'.
Failing descriptor: {markup://c:NewAccount}"



User-added image
Hi All,

I have formula field of text datatype. It used to captured QR code of each Campaign Member Record.
On VFPage it's working fine.
But on Render as PDF, it shows currepted image.

Following is the formula field :
QR Code :
IMAGE('https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl=MECARD://tjt--aresssbox.cs64.my.salesforce.com/'&Id ,'Scan QR code to open record in mobile.')
Hi,

I want to copy value of "discounted box price(Currency field)" in to the standard field "Unit Price" of OrderLineItem Object.
I have tryed using Workflow rule. Its working but it can not fullfill my requirment. So,I want trigger to copy "discounted box price" to "Unit Price".
Please let me know the solution.

Thanks, in advanced.
Puja
Hi,
I have following After Update Trigger... I have to write test class for same...
Please some one help me..?

trigger AccountChanged on Asset (after update) {

    List<Opportunity> OppList= new List<Opportunity>();
   
    for (Asset newAsset : Trigger.new) {

                                        // If account of equipment is changed..
        if ( newAsset.AccountId != Trigger.oldMap.get( newAsset.Id ).AccountId ){    
            
                                        //Create new Opportunity for Sales i.e. OEM Record Type...
            Opportunity newOpp1 = new Opportunity();
            
            Id oppRecordTypeId1 = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('OEM').getRecordTypeId();
            newOpp1.RecordTypeId = oppRecordTypeId1;
            
            
            newOpp1.Asset__c = newAsset.id;
            newOpp1.Name = 'New Sales Opportunity';
            newOpp1.AccountId = newAsset.AccountId;
            newOpp1.StageName = 'Qualification';
            newOpp1.CloseDate = system.today();
            

            OppList.add(newOpp1);
            
          
                                            //Create new Opportunity for Parts i.e. Parts Record Type...
            Opportunity newOpp2 = new Opportunity();
            
            Id oppRecordTypeId2 = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('Parts').getRecordTypeId();
            newOpp2.RecordTypeId = oppRecordTypeId2;
            
            
            newOpp2.Asset__c = newAsset.id;
            newOpp2.Name = 'New Parts Opportunity';
            newOpp2.AccountId = newAsset.AccountId;
            newOpp2.StageName = 'Qualification';
            newOpp2.CloseDate = system.today();
            

            OppList.add(newOpp2);
            
            If(OppList.Size()>0){
            Insert OppList;
            }
        }

    }
}