• Pankaj Yadav 16
  • NEWBIE
  • 5 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 20
    Replies
For ex: if there are four territories as below examples.
A-->B-->C-->D

And four different and similar user assigned on each territories, then how to create report to know how many territories assigned on each user.
How to change global search setting for Tasks object in salesforce, already checked activity object.
I have craeated one check box field in Account object and i want to create a button in visualforce page to activate and detivate the check box option. Please help slected
Requirement - Selected records or multiple records at a time.
Please let me know the logic and appriciate your help.

Apex code:
public class ActiveAccAss2
{
private integer totalRecs = 0;
private integer OffsetSize = 0;
private integer LimitSize= 10;
   
public ActiveAccAss2()
{
totalRecs = [select count() from account];
}
   
public List<account> getacclist()
{
List<account> acc = Database.Query('SELECT Name, website, AnnualRevenue, description, Type FROM account LIMIT :LimitSize OFFSET :OffsetSize');
System.debug('Values are ' + acc);
return acc;
}
   
public void FirstPage()
{
OffsetSize = 0;
}
   
public void previous()
{
OffsetSize = OffsetSize-LimitSize;
}
   
public void next()
{
OffsetSize = OffsetSize + LimitSize;
}public void LastPage()
{
OffsetSize = totalrecs-math.mod(totalRecs,LimitSize);
}
public boolean getprev()
{
if(OffsetSize == 0)
return true;
else
return false;
}
public boolean getnxt()
{
if((OffsetSize + LimitSize) > totalRecs)
return true;
else
return false;
}
}

Visual force code
<apex:page controller="ActiveAccAss2" >
<apex:form >
<apex:pageBlock id="details">
<apex:pageblockTable value="{!acclist}" var="acc">
    <apex:column >
    <apex:inputCheckbox />
    </apex:column>
<apex:column value="{!acc.Name}"/>
<apex:column value="{!acc.website}"/>
<apex:column value="{!acc.AnnualRevenue}"/>
<apex:column value="{!acc.Description}"/>
<apex:column value="{!acc.Type}"/>
</apex:pageblockTable>
<apex:pageblockButtons >
<apex:commandButton value="Activate/Inactivate"/>
<apex:commandButton value="Delete"/>
</apex:pageblockButtons>
   
<apex:pageblockButtons >
<apex:commandButton value="First Page" rerender="details" action="{!FirstPage}" disabled="{!prev}"/>
<apex:commandButton value="Previous" rerender="details" action="{!previous}" disabled="{!prev}"/>
<apex:commandButton value="Next" rerender="details" action="{!next}" disabled="{!nxt}"/>
<apex:commandButton value="Last Page" rerender="details" action="{!LastPage}" disabled="{!nxt}"/>"
</apex:pageblockButtons>
</apex:pageBlock>
   
    </apex:form>
</apex:page>
How to create a task as per type value in Account object by trigger class.

Trigger
public class Helperdemo {

    List<Task> TaskCreated = new List<Task>();
    
    public void Acctask(List<Account> acclist)
        {
        if(acclist.size()>0)
        {
            for(Account a:acclist)
            {
                    if(a.Type=='Prospect')
                    {
                        Task t = new Task();
                        t.Subject ='Prospect task';
                        TaskCreated.add(t);
                     }
            }
    if(TaskCreated.size()>0)
    {
        
        insert TaskCreated;
    }
        }
            
        
    }
    
}

Apex class
trigger Demo on Account (before insert, after insert) {

    Helperdemo hd;
        hd.Acctask(trigger.new);
    
    }
    
What is the issue in above code.
For ex: if there are four territories as below examples.
A-->B-->C-->D

And four different and similar user assigned on each territories, then how to create report to know how many territories assigned on each user.
I have craeated one check box field in Account object and i want to create a button in visualforce page to activate and detivate the check box option. Please help slected
Requirement - Selected records or multiple records at a time.
Please let me know the logic and appriciate your help.

Apex code:
public class ActiveAccAss2
{
private integer totalRecs = 0;
private integer OffsetSize = 0;
private integer LimitSize= 10;
   
public ActiveAccAss2()
{
totalRecs = [select count() from account];
}
   
public List<account> getacclist()
{
List<account> acc = Database.Query('SELECT Name, website, AnnualRevenue, description, Type FROM account LIMIT :LimitSize OFFSET :OffsetSize');
System.debug('Values are ' + acc);
return acc;
}
   
public void FirstPage()
{
OffsetSize = 0;
}
   
public void previous()
{
OffsetSize = OffsetSize-LimitSize;
}
   
public void next()
{
OffsetSize = OffsetSize + LimitSize;
}public void LastPage()
{
OffsetSize = totalrecs-math.mod(totalRecs,LimitSize);
}
public boolean getprev()
{
if(OffsetSize == 0)
return true;
else
return false;
}
public boolean getnxt()
{
if((OffsetSize + LimitSize) > totalRecs)
return true;
else
return false;
}
}

Visual force code
<apex:page controller="ActiveAccAss2" >
<apex:form >
<apex:pageBlock id="details">
<apex:pageblockTable value="{!acclist}" var="acc">
    <apex:column >
    <apex:inputCheckbox />
    </apex:column>
<apex:column value="{!acc.Name}"/>
<apex:column value="{!acc.website}"/>
<apex:column value="{!acc.AnnualRevenue}"/>
<apex:column value="{!acc.Description}"/>
<apex:column value="{!acc.Type}"/>
</apex:pageblockTable>
<apex:pageblockButtons >
<apex:commandButton value="Activate/Inactivate"/>
<apex:commandButton value="Delete"/>
</apex:pageblockButtons>
   
<apex:pageblockButtons >
<apex:commandButton value="First Page" rerender="details" action="{!FirstPage}" disabled="{!prev}"/>
<apex:commandButton value="Previous" rerender="details" action="{!previous}" disabled="{!prev}"/>
<apex:commandButton value="Next" rerender="details" action="{!next}" disabled="{!nxt}"/>
<apex:commandButton value="Last Page" rerender="details" action="{!LastPage}" disabled="{!nxt}"/>"
</apex:pageblockButtons>
</apex:pageBlock>
   
    </apex:form>
</apex:page>
The challenge in this trailhead https://trailhead.salesforce.com/modules/sales_admin_sales_reports_for_lex/units/sales_admin_sales_reports_unit_3 is giving the error . Error is 
There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: KMBSDJYC
Example want to break 10 into 3 parts so there are multiple combinations
like 2+2+6, 1+2+7, 1+6+3... etc.
Help me is there any way to achieve this in salesforce using apex ?
Hi,
I have two objects. Object1 and Object2.
I have 10 fields in object1. After creating a record in object1, I want to create a record in Object2.
I want only 3 field values from Object1.
If anyone have code syntax, please share.

Thanks in Advance

Regards,
Hari