• swati_sehrawat
  • NEWBIE
  • 355 Points
  • Member since 2016
  • NSI

  • Chatter
    Feed
  • 11
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 74
    Replies
Hi
i am almost there but i can't move on as i have an error message saying that "The process did not set the correct Type value on submitting for approval"
Who can help me ?
Thanks
User-added image
Hello,

If i have a triggers on account,
If the trigger goes in exception loop, i want to display a error mesage "not valied" on the page and halt further proceeding of the page, i mean not let the user to save the page..

how can this be done
  • August 25, 2016
  • Like
  • 0
Hi All,

Q). what is the difference between actionFunction and actionSupport, Explain with funcionality?

can anyone reply for this post...
Thanks in advance..
When checking the challenge at step 4 I recieved this error -

There was an unhandled exception. Please reference ID: TWMJUUNP. Error: ArgumentError. Message: bad argument (expected URI object or URI string)

Can anyone provide some insight on where to begin looking to fix this error?

Thanks!
List<contact> conlist= new list<contact>();
conlist.add(FirstName='joe', Department='Finance');
conlist.add(FirstName='kathy', Department='Technology');
conlist.add(FirstName='caroline', Department='Finance');
conlist.add(FirstName='kim', Department='Education');


insert conlist;

list<contact> lstUpdate = new list<contact>();
for(contact con: conlist)
{
    if(Department=='Finance')
    {
        con.Title='Financial Analyst';
    lstUpdate.add(con);
}
}
update lstUpdate;
Hi Team,

Can any one please help me to create test class for below trigger.

rigger Task on Opportunity (after insert,after update){    
    List<Opportunity> listOpp = Trigger.new;
    List<Task> listTask = new List<Task>();    
       if(Trigger.isInsert){
        for(Opportunity opp:listOpp){              
           if(opp.Help__c != null){
                Task t = new Task();
                t.OwnerId = opp.OwnerId;
                t.WhatId = opp.Id;
                t.Subject ='Help' + ': ' +opp.Help__c ; 
                t.ActivityDate = System.Today()+7;  
                t.Description = opp.Description__c;
                t.Status = 'In Progress';
                t.Priority = 'Normal';
                listTask.add(t);
            } 
        }
    }   

     if(Trigger.isUpdate){
         Map<Id,Opportunity> oldOppMap = Trigger.oldmap;
        for(Opportunity opp:listOpp){
            if(Opp.Help__c != oldOppMap.get(opp.Id).Help__c || Opp.Description__c!= oldOppMap.get(opp.Id).Description__c ){
            Task t = new Task();
            t.WhatId = opp.Id;   
            t.Subject = 'Help' + ': ' +opp.Help__c ; 
            t.Description = opp.Description__c;  
            t.ActivityDate = System.Today()+7;
            t.Status = 'In Progress';
            t.Priority = 'Normal';        
            listTask.add(t);
         }
        }   
     }  
     insert listTask;
 }

Thanks in Advance
1.Why are we getting error When we query like this in query editor?
SELECT Name, (SELECT Name FROM OpportunityLineItem)  FROM Product2

2.Is there any relationship between Product2 and OpportunityLineItem because i see relationship in schema builder but cannot see any relation field in opportunity line item to product2
  • August 24, 2016
  • Like
  • 0
For some reason I am stucked at 53% and I don't know what I am missing.

here is my trigger:
 
trigger activityTrigger on Task (after insert, after update) {
    set<id> oppIds = new set<id>();
    //map<id,Task> mapTask = new map<id,Task>();
    
    if(trigger.isafter){
        if(trigger.isInsert){
            for(Task loopTask:trigger.new){
                if(loopTask.WhatId != null && string.valueof(loopTask.whatid).startsWith('006')){
                    
                    oppIds.add(loopTask.WhatId);
                    //mapTask.put(loopTask.Id, loopTask);
                }
            }
            
            list<Opportunity> opportunityList = new list<Opportunity>([ SELECT id, test_first_activity__c, 
                                                                        (SELECT Id, Status,Subject,Type, CreatedDate, whatId  FROM Tasks order by CreatedDate asc limit 1) 
                                                                        FROM Opportunity Where id IN: oppIds ]); 
            list<Task> taskList = new list<Task>();
            
            if(oppIds.size() > 0){ 
                for(Opportunity loopOpp : opportunityList  ){
                    
                    if(loopOpp.getSobjects('Tasks') != null && loopOpp.getSobjects('Tasks').size() > 0) 
                    taskList = loopOpp.getSobjects('Tasks'); 
                    
                    if(taskList[0].whatId == loopOpp.id){
                        if(taskList[0].Status != null && taskList[0].Status.equalsignorecase('Completed') ){
                            loopOpp.test_first_activity__c = taskList[0].CreatedDate;
                        }
                    }
                }
            }
            update opportunityList;
        }
        
        if(trigger.isUpdate){
            for(Task loopTask:trigger.new){
                if(loopTask.WhatId != null && string.valueof(loopTask.whatid).startsWith('006')){
                    
                    oppIds.add(loopTask.WhatId);
                    //mapTask.put(loopTask.Id, loopTask);
                }
            }
            
            list<Opportunity> opportunityList = new list<Opportunity>([ SELECT id, test_first_activity__c, 
                                                                        (SELECT Id, Status,Subject,Type, CreatedDate, whatId  FROM Tasks order by CreatedDate asc limit 1) 
                                                                        FROM Opportunity Where id IN: oppIds ]); 
            list<Task> taskList = new list<Task>();
            
            if(oppIds.size() > 0){ 
                for(Opportunity loopOpp : opportunityList  ){
                    
                    if(loopOpp.getSobjects('Tasks') != null && loopOpp.getSobjects('Tasks').size() > 0) 
                    taskList = loopOpp.getSobjects('Tasks'); 
                    
                    if(taskList[0].whatId == loopOpp.id){
                        if(taskList[0].Status != null && taskList[0].Status.equalsignorecase('Completed') ){
                            loopOpp.test_first_activity__c = taskList[0].CreatedDate;
                        }
                    }
                }
            }
            update opportunityList;
        }
    }
    
}

And here is my unit test
 
@isTest
public class PounceTime_Test {
    
    static testMethod void PounceTime() {
        
         Account a = new Account();
   		 a.Name = 'Account';
        
        
        insert a;
        
        Contact c = new Contact();
        c.LastName = 'Kash';
        c.AccountId = a.Id;
        
        insert c;
        
        
        Opportunity o = new Opportunity();
        o.Name = 'MyOpps';
        o.StageName = 'New';
        o.CloseDate = Date.today().addDays(7);
        o.Discount__c = 1;
        o.test_first_activity__c = Datetime.now();
        o.Contact__c = c.Id;
       
      insert o;
   
      
        
        List<Task> tasks = new List<Task>();
		 tasks.add(new Task(
   		 ActivityDate = Date.today().addDays(7),
   		 Subject='Sample Task',
    	 WhatId = o.Id,
         WhoId = c.Id,
         Priority = 'Normal',
   		 OwnerId = UserInfo.getUserId(),
    	 Status='In Progress'));

		insert tasks;
    }

}

Thank you in advance.!
  • August 24, 2016
  • Like
  • 0
Hi All,

I have written test class for one of my VF Page & covered upto 73% but i failed to cover morethan 75%. Here is my VF Page & Apex Classes
 
<apex:page controller="DataTableEditRemoveController">
<apex:form id="form" >
<apex:pageBlock title="Accounts">
<apex:pageMessages ></apex:pageMessages>
<apex:pageBlockTable value="{!accs}" var="acc">
<apex:column >
<apex:outputLink title="" value="/{!acc.id}/e?retURL=/apex/{!$CurrentPage.Name}" style="font-weight:bold">Edit</apex:outputLink>&nbsp;|&nbsp;
<apex:commandLink action="{!DeleteAccount}" onclick="return confirm('Are you sure?')" value="Del">
    <apex:param value="{!acc.Id}" name="accountid" assignTo="{!SelectedAccountId}"/>
</apex:commandLink>
</apex:column>
<apex:column value="{!acc.Name}"/>
<apex:column value="{!acc.BillingStreet}"/>
<apex:column value="{!acc.BillingCity}"/>
<apex:column value="{!acc.BillingPostalCode}"/>
<apex:column value="{!acc.BillingCountry}"/>    
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>      
</apex:page>

Here is Controller
 
public class DataTableEditRemoveController {

    public String getRow() {
        return null;
    }

public List<Account> accs { get; set; }

//used to get a hold of the account record selected for deletion
public string SelectedAccountId { get; set; }

public DataTableEditRemoveController() {
//load account data into our DataTable
LoadData();
}

@Testvisible
private void LoadData() {
system.debug('Enter In the Constructor*****');
accs = [Select id, name, BillingStreet, BillingCity, BillingPostalCode, BillingCountry from Account limit 20];
}

public PageReference DeleteAccount()
{
System.debug('SelectedAccountId: '+SelectedAccountId);
accs = [select id,name, BillingStreet, BillingCity, BillingPostalCode, BillingCountry from Account where id=:SelectedAccountId];
System.debug('SIZEOFACC: '+accs.size());
if(accs.size()>0 && accs[0]!= null){
delete accs;
System.debug('DELSIZEOFACC: '+accs.size());
SelectedAccountId = null;

}

//refresh the data
LoadData();
    return null;
}


}

Here is 29 th line is not covered ...............


Here is My Test Class
 
@istest
public class DataTableEditRemoveController_Test{
static testmethod void Method_Test(){

    Account acc = new Account();
    acc.name = 'Test';
    acc.Fax = '555555';
    acc.BillingStreet = 'Korlagunta';
    acc.BillingCity = 'Tirupati';
    acc.BillingPostalCode = 'Tiruapti';
    acc.BillingCountry = 'INDIA';
    insert acc;
    
   // Delete acc;
  system.debug('ACCID******'+acc.id);  
    Test.starttest();
    pagereference pageref = page.Edit_Del_Hyperlink_Fun;
    Test.SetCurrentPageReference(pageref);
    pageref.getParameters().put('SelectedAccountId', String.valueOf(acc.Id));
  string STRID = apexpages.currentpage().getparameters().put('SelectedAccountId',acc.id);
   System.assertEquals(STRID, acc.Id, 'ID\'s should match');
   system.debug('PARAMID******'+apexpages.currentpage().getparameters().put('SelectedAccountId',acc.id)); 
    DataTableEditRemoveController contrll = new DataTableEditRemoveController ();
    contrll.LoadData();
    contrll.DeleteAccount();
    list<Account> a =[select id,name, BillingStreet, BillingCity, BillingPostalCode, BillingCountry from Account where id=:STRID];
    system.debug('LSTACCID******'+a.size());
    Delete a;
    Test.stoptest();

I have checked the debugs, SelectedAccountId its coming in test class but not in main controller..........I am struck here .......Please give me your valuable suggestions.......

Adv Thnx
VSK98
  • August 24, 2016
  • Like
  • 0
Hi All,

Trying to improve the code coverage of a test class I've written. The trigger is meant to unset a checkbox on the opportunity after the opportunity line items are updated, the checkbox is True and the line items have revenue schedules. Right now it's at 31% but I'm unsure how to replicate the necessary actions to push it beyond that? Any advice is appreciated! I'm trying to avoid becoming one of those developers whose code barely makes it to production. Here's the trigger I'm trying to cover and below that is the class that I've written so far. 

Trigger:
trigger unsetScheduler on OpportunityLineItem (after update) 
{
	Set<Id> setId = new Set<Id>();
	for (OpportunityLineItem allLineItems : trigger.new) 
	{
		if(allLineItems.HasRevenueSchedule == true)
		{
			setId.add(allLineItems.OpportunityId);
		}	
	}
	
	if(setId.size() > 0 )
	{
		Map<Id,Opportunity> mapOpp = new Map<Id,Opportunity>( [select id,Scheduling__c from Opportunity where id in :setId and Scheduling__c = true]);
		List<Opportunity> lstOppToUpdate = new List<Opportunity>();
		
		for (OpportunityLineItem allLineItems: trigger.new)
		{
			if(allLineItems.HasRevenueSchedule == true && mapOpp.containsKey(allLineItems.OpportunityId) )
			{ 
				Opportunity opp = mapOpp.get(allLineItems.OpportunityId);
				
				opp.Scheduling__c = false;
				lstOppToUpdate.add(opp);
			} 
		}
		if(lstOppToUpdate.size()>0)
		{
			update lstOppToUpdate;
		}
	}	
	
}

Class:
@isTest
public class testUnsetScheduler {
    static testMethod void updateLineItem() {
        
        Account acc = new Account();
        acc.Name = 'Test Account';
        
        insert acc;
        
        Opportunity opp = new Opportunity();
        opp.Name = 'TestOpportunity';
        opp.AccountId = acc.Id;
        opp.CloseDate = System.Today().addDays(10);
        opp.StageName = 'Negotiation';
        opp.Projected_Start_Date__c = System.Today().addDays(15);
        opp.Projected_End_Date__c = System.Today().addDays(20);
        opp.Type = 'Media';
        opp.Programmatic_TV_Rev__c = 'No';
        opp.Scheduling__c = True;
        
        insert opp;
                  
        OpportunityLineItem oli = new OpportunityLineItem();
        oli.OpportunityId = opp.Id;
        oli.Budget__c = 10000;
        oli.New_Rate__c = 0.05;
        oli.UnitPrice = 0;
        oli.Quantity = 1;
        oli.PricebookEntryId = '01u7000000GB8I1';
        
        insert oli;
        
        oli.Budget__c = 15000;
        oli.New_Rate__c = 0.10;
        update oli;
       
    } 
}

 
I  should start by saying I know very little about Java. I have pieced together a custom button that is used to update the open case record. The button works flawlessly, but I want to add code to check if its assigned to a user, and if it is, execute only the portion of the code that changes the priority. If its assigned to a queue, then the changes for Owner, Priority, and Status would need to execute. 

The code current code I have is:

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

var caseObj = new sforce.SObject("Case"); 
caseObj.Id = '{!Case.Id}'; 
caseObj.OwnerId = '00G36000001rInD'; 
caseObj.Status = "Ready to Move Forward"; 
caseObj.Priority = 'High' 
var result = sforce.connection.update([caseObj]); 
window.location.href=window.location.href;
Hi
I am just learning custom settings and here is my code.
I created a custom setting name as CustAccount and inserted 3 records having fields ID and Name, both are type Text.
public class customsettings
{
   public List<CustAccount__c> code { get; set; }
   public customsettings()
   {
     code=CustAccount__c.getall().values();
   }
}
<apex:page controller="customsettings">
 <apex:form >
 <apex:pageBlock >
 <apex:pageBlockTable value="{!code}"
                      var="a">
                      
         <apex:column value="{!a.Name}"/>  
     </apex:pageBlockTable>
 </apex:pageBlock>
 </apex:form>
</apex:page>

Now I want to update single record at a time.
Please tell me how this can be achieved.

Thanks
sonali verma
 
public class UpsertDml {
    public list<Account> acc{get;set;}
    //default constructor1
    public UpsertDml(){
        acc=new list<Account>();
    }
    public void upsertAccount()
    {
        Account a = new Account(Name='krishna');
        try{
             insert a;
        }catch(Exception e){
             system.debug('Record '+a.Name +' inserted successfully');
        }
        List<Account> accounts=[SELECT id,name FROM Account WHERE name='kanusupdated'];
        If(accounts.size() > 0){
            try{
             for(Account a1:accounts)
                {
                if(a1.name=='kanusupdated')
                {
                    Account a2=new Account();
                    a2.id=a1.id;
                    a2.name='kanus updated';
                    acc.add(a2);
                }
             }
                    update acc;
                system.debug('records were updated successfully===='+acc);     
            }catch(DMLException e){
                system.debug('records were not updated====='+e);
            }
     
       }
   }
}

testclass.
@isTest
public class upsertDml_Test {
    //to cover first Exception
    public static testMethod void main1Method(){
        Account a = new Account();
        a.Name='krihna';
        a.BillingCity='khhgkg';
        insert a;
        upsertDml sc = new upsertDml();
        sc.upsertAccount();
    }
    public static testmethod list<Account> recordCreation(){      
        List<Account> ac = new List<Account>();
        Account a = new Account();
        a.Name = 'kanusupdated'; 
        ac.add(a);
        return ac;      
    } 
    public static testmethod void P_main(){
        Test.startTest();
        list<Account> acc1 = recordCreation();
        insert acc1;   
        upsertDml sc = new upsertDml();
        sc.acc = recordCreation();
        system.debug('values in sc.acc ============='+sc.acc);
        sc.upsertAccount();
        Test.stopTest();
    }
    
}
Hello, 

I created a custom formula text field in the opportunity object called, MAS__c.

It should pull the first name and last name referenced to the User object. But what i get is the 15 digit ID vs the text name. 

This is the formula syntax I used in the MAS__c formula text field: 
 
$User.MAS__c

Any idea on how to do this via a formula or process builder? 

I tried process builder but not sure what the syntax would be and my attempt was to create a custom field MASda__c, then populate it using the User object:
[Opportunity].MASda__c = $User.FirstName

 
Hello. Regarding SalesForce training for SalesForce Administrator certification, I have just started the TrailHead instruction. In my Setup or Developer org, I am not seeing the link button which allows me to create an app. I have looked at the help, but still don't see it. My context says BMC RemedyForce.

Am I doing something wrong, or could it be that my org instance is not properly enabled? What I see does not look like the Setup screen or Developer org in the video.

Thank you!
Stephen
Hi all,

I've seen lots of topics and discussions here about picklist values based on record type on a standard VF page, but I have a little more complicated problem.

I am trying to get around the problem mentioned here: https://success.salesforce.com/ideaView?id=08730000000BpNb

I have built a visualforce page with a standard list controller and no extensions, with a custom list view button to open the page after several case records have been selected.

The VF page contains 2 picklists: Status and SubStatus (dependent picklist, with different values based on Case record type).

The problem I am facing is this: How does Salesforce decide which set of SubStatus values to show in the dropdown, if I have selected multiple records on the list view that may have different record types?

At the very least, I want to be able to show ALL possible values, regardless of selected records' record types.

I was trying to build this without custom controllers or extensions, but I think I may have to build the SubStatus picklist dynamically.

Any advice or tips how to do this?  

VF Page:
<apex:page standardController="Case" recordSetVar="cases" tabStyle="Case">
    <apex:form id="form">
        <apex:pageBlock title="Mass Close Cases" mode="edit" id="block">
            <apex:pageMessages />
            <apex:pageBlockButtons location="top">
                <apex:commandButton value="Save" action="{!save}"/>
                <apex:commandButton value="Cancel" action="{!cancel}"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="Case Information" columns="1" id="section">
            <apex:pageBlockSectionItem id="sectionItem1">
                <apex:outputLabel value="Status" />
                <apex:inputField id="statusval" value="{!case.Status}"/>
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem >
                <apex:outputLabel value="SubStatus" />
                <apex:inputField required="true" Value="{!case.SubStatus__c}"/>
            </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
Thanks,
Tony
Hi
i am almost there but i can't move on as i have an error message saying that "The process did not set the correct Type value on submitting for approval"
Who can help me ?
Thanks
User-added image
Hello,

If i have a triggers on account,
If the trigger goes in exception loop, i want to display a error mesage "not valied" on the page and halt further proceeding of the page, i mean not let the user to save the page..

how can this be done
  • August 25, 2016
  • Like
  • 0
Hi Developers.
i have a custom button link called "new incident" after clicking on link i am redirected to another vf page.the screen shot is belowUser-added image
After clicking on new incident i am redirectin to below page:
User-added image
I want to populate client id field with current user,and bussiness unit as PHS:
Plz help me out.
thanks in advance.
Hi All,

Q). what is the difference between actionFunction and actionSupport, Explain with funcionality?

can anyone reply for this post...
Thanks in advance..
Hi all, I'm new to SF. I'm trying to fetch Opportunity records in a VF page using FromAmount and Toamount, dymically using database.query.
Any help on this would be very useful Your help much appreciated. Thanks.
Hi.

We have added a custom button called 'upload file' to Opportunity object in Lightning. When click on a button, it will navigate to Visual Force Page, which included a lightning component.

The above button is visible for newly created Opportunities, but not to the old opportunities. We are using Developer Edition. Can you please suggest us on this issue.

Regards
Jansi
At our company we have 2 record types for Opportunty pages (Page A and Page B). What I am trying to do is that when a sales person is creating a new opportunity if they select the "Page B" Opportunity record type I want a specific Product (at our company we call them Services) to be automatically selected for that new opportunity.

I have tried to use a workflow but that does not work because it can't reference two different object (the Opportunity object and the Product object). I am assuming I will need to create a trigger for this but I pretty new to using triggers, I have tried for quite a while and haven't gotten anywhere close. Any help is greatly appreciated!