• ANITHA BEEMU 2
  • NEWBIE
  • 40 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 18
    Questions
  • 29
    Replies
HI i am having a users who is in high hierachy  having modify all and delete access on opportunity and documents and OWD for opportunities is REad/write,BUt user is not able to delete files on opportunity of his lower level users record.can anyone pls help
i need a formula on process builder,with critriea opportunity stage closed won,Referral (custom field) not null and contract term <3 years

i have conterm term a picklist field with values 12,24,36,48,60,72 all in months

for <3 years one formula
for  3 years one formula and 
for 4+ years one formula

i tired following one,getting error:
AND( 
OR( 
ISPICKVAL([Opportunity].StageName , "Closed Won"), 
OR( 
 NOT ( ISBLANK ( [Opportunity].Referral__c )  ), 
OR( 
ISPICKVAL([Opportunity].ContractTerm__c <36 )) ) 
)
)


please help me in this
 
HI all,
i have custom object called locations which is master detail relationship with opportunities,now i want a button (existing location)on the related list of locations in the opportunitypage.i tired below code:

apex code:
public with sharing class ExiLocExtController {

 

    public Opportunity opportunity  { get; set; }

     

    public ExiLocExtController() {

         

        String OpportunityId = ApexPages.currentPage().getParameters().get('id');

        Opportunity = [SELECT Id, Name, Location__c FROM Opportunity WHERE Id =: OpportunityId];

         

    }

     

    public PageReference save () {

         

        Location__c LOC = new Location__c ( Id = Opportunity.Location__c, Opportunity_Name__c = Opportunity.Id);

         

        try {

            Database.update(LOC);

        } catch (Exception error) {

            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Error while associating.' + error.getMessage()));
       }

         

        PageReference page = new PageReference('/' + Opportunity.Id);

         

        return page.setRedirect(true);

    }

     

    public PageReference cancel () {

        PageReference page = new PageReference('/' + Opportunity.Id);

        return page.setRedirect(true);        

    }


}
visual page:

<apex:page controller="ExiLocExtController">
 <apex:form >

        <apex:pageblock title="ExistingLocationto test">

            <apex:pageMessages />

            <apex:pageblockbuttons location="top">

                <apex:commandbutton value="save" action="{!save}" />

                <apex:commandbutton value="Cancel" action="{!cancel}"/>

            </apex:pageblockbuttons>

            <apex:pageBlockSection >

                <apex:pageBlockSectionItem >

                    <apex:outputLabel >Opportunity Name</apex:outputLabel>

                    <apex:outputText >{!Opportunity.Name}</apex:outputText>  

                </apex:pageBlockSectionItem>

              <apex:pageBlockSectionItem >

                    <apex:outputLabel >Location__c</apex:outputLabel>

                    <apex:inputField value="{!Opportunity.Location__c}"/>

                </apex:pageBlockSectionItem>               

            </apex:pageBlockSection>

        </apex:pageblock>

    </apex:form>

</apex:page>

i am able to open the page,but that is not saving to the opportunity,kindly help me.
 
HI all,
i have custom object called locations which is master detail relationship with opportunities,now i want a button (existing location)on the related list of locations in the opportunitypage.i tired 

1-) Create a custom related list button in Opportunity as shown below:




2-) Add the url below to your button:

/apex/AssociateOpportunity?id={!Account.Id}

3-) Add the button to the Opportunity's related list in Account's page layout:





4-) Create a custom lookup field for Opportunity in Account (this is a trick to get the lookup field of Opportunity working in the Visualforce). This button won't be visible and will not be added to any layouts and won't include any related list.




5-) Create a controller class (I named it AssociateOpportunityExtController): 
 
01public with sharing class AssociateOpportunityExtController {
02 
03    public Account account  { get; set; }
04     
05    public AssociateOpportunityExtController() {
06         
07        String accountId = ApexPages.currentPage().getParameters().get('id');
08        account = [SELECT Id, Name, Opportunity__c FROM Account WHERE Id =: accountId];
09         
10    }
11     
12    public PageReference associate () {
13         
14        Opportunity opp = new Opportunity ( Id = account.Opportunity__c, AccountId = account.Id);
15         
16        try {
17            Database.update(opp);
18        } catch (Exception error) {
19            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Error while associating.' + error.getMessage()));
20        }
21         
22        PageReference page = new PageReference('/' + account.Id);
23         
24        return page.setRedirect(true);
25    }
26     
27    public PageReference cancel () {
28        PageReference page = new PageReference('/' + account.Id);
29        return page.setRedirect(true);       
30    }
31     
32}
6-) Create a Visualforce (I named it AssociateOpportunity):
 
01<apex:page controller="AssociateOpportunityExtController">
02    <apex:form>
03        <apex:pageblock title="Associate Opportunity to Custom Object">
04            <apex:pageMessages />
05            <apex:pageblockbuttons location="top">
06                <apex:commandbutton value="Associate" action="{!associate}" />
07                <apex:commandbutton value="Cancel" action="{!cancel}"/>
08            </apex:pageblockbuttons>
09            <apex:pageBlockSection>
10                <apex:pageBlockSectionItem>
11                    <apex:outputLabel>Account Name</apex:outputLabel>
12                    <apex:outputText>{!account.Name}</apex:outputText>  
13                </apex:pageBlockSectionItem>
14              <apex:pageBlockSectionItem>
15                    <apex:outputLabel>Opportunity</apex:outputLabel>
16                    <apex:inputField value="{!account.Opportunity__c}"/>
17                </apex:pageBlockSectionItem>               
18            </apex:pageBlockSection>
19        </apex:pageblock>
20    </apex:form>
21</apex:page>

(i changed objectnames as in above its for different object) after following this getting error "Namespace length cannot exceed 15 chars "..
can any one help pls.
I tired following code :

Trigger CopyopportunityAttachtoAccount on Attachment (after insert)     
{
    set<id> Oppids=new set<id>();
    Map<id, attachment> OpportunityAttachments = new Map<id, attachment>();
    Map<id, Opportunity> OpportunitiesWithAccount = new Map<id, Opportunity>();
    for(attachment an:trigger.new)
    {
        if(an.ParentId.getSobjectType() == Opportunity.SobjectType) OpportunityAttachments.put(an.ParentId, an);
            //Oppids.add(an.ParentId);
    }
    // not required, as using soql 
    // list<Opportunity> OppAccmap =new list<Opportunity>([Select Account.id,Account.name from Opportunity where Id In:Oppids]);

    list<attachment> accatt=new list<attachment>();
    //for(Opportunity Ot:OppAccmap){
    // read "Explanation" why I have replaced Soql For loop with your approach
    if (OpportunityAttachments.keySet().size() > 0) // Read "Explanation" why this check is introduced.
    {
        OpportunitiesWithAccount = new Map<Id, Opportunity>([SELECT Id, Account.id FROM Opportunity WHERE Id IN :OpportunityAttachments.keySet()]);
        // for (attachment am :[select id, name,parentId, body from Attachment where ParentId in :Oppids]) // soql inside for loop is bad, bad thing.
        for (attachment am: OpportunityAttachments.values() ) 
        {
            if (OpportunitiesWithAccount.containsKey(am.ParentId) )
            {
                Attachment newFile = New Attachment(Name = am.name, body = am.body, ParentId=OpportunitiesWithAccount(am.ParentId);
                accatt.add(newFile);
            }
        }
    }
    insert accatt;
}

GETTING ERROE OVER HERE:

Attachment newFile = New Attachment(Name = am.name, body = am.body, ParentId=OpportunitiesWithAccount(am.ParentId);
                accatt.add(newFile);

AND Incorrect SObject type ..PLS DO HELP