• sachin sabu
  • NEWBIE
  • 40 Points
  • Member since 2016


  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 1
    Questions
  • 9
    Replies
trigger NoteOnContentDocument on ContentDocument (before delete) {
    for (ContentDocument c : Trigger.old){
        List<ContentDocumentLink> links = [
            SELECT LinkedEntityId 
            FROM ContentDocumentLink 
            WHERE ContentDocumentId= :c.Id
        ];
        if (Approval.isLocked(links.get(1).LinkedEntityId)){
            c.addError('Approval pending. You do not have the permission to delete this note, Please contact your administrator.');
           }    
    }
}

 
How To Redirect toa new VF Page when a Button clicked &&
how to upload an image in VF, like upload profile pic..
 
Hi all, 

I'm learning triggers in salesforce and want some advice on understanding how to write a trigger for below scenario. what is the approach?

There are two objects ObjectPar__c(Parent) and ObjectCh__c(child) having look-up relationship.

Summary:
ObjectPar__c has record types namely  "A" and "B".
ObjectPar__c has a field (currency) --> Myamount__c
ObjectPar__c has 2 picklislts --> Picklist_a__c and Pciklist_b__c
ObjectCh__c has a field(curreny_ --> amount__c)

Scenario:

when amount__c(on ObjectCh__c(childobject)) is blank or null, and if record type is either A||B and Picklst_a__c and picklist__b (on parent) is selected then Myamount__c should be required it cannot be blank
 
I have the following apex and visualforce. 

I have added a commandbutton at the top of the visualforce page, but i want the click to open in a new window. Right now it is opening in the VF window. 

I also want to have the ability to let the user sort the columns by clicking on the column header. 

VisualForce
<apex:page controller="Pagination_min">
    <apex:form >
            <apex:commandButton value="New Opportunity" action="https://cs15.salesforce.com/006/e?retURL=%2F006%2Fo&RecordType=01240000000Uexl&ent=Opportunity"/>
       <apex:pageBlock id="pb">
       
            <apex:pageBlockTable value="{!opps}" var="o">
                <apex:column headerValue="Opportunity Name">  
                      <apex:outputlink value="/{!o.id}" target="__blank">{!o.Name}</apex:outputlink>  
                </apex:column>                  
                <apex:column value="{!o.StageName}"/>
                <apex:column value="{!o.FED__c}"/>
                <apex:column headerValue="Broker">
                <apex:outputlink value="/{!o.Broker__c}" target="__blank">{!o.Broker_Name__c}</apex:outputlink>  
                 </apex:column>    
                <apex:column value="{!o.Core_Product__c}"/>
                <apex:column value="{!o.LeadSource}"/>
                <apex:column value="{!o.Number_Quoted__c}"/>
                <apex:column value="{!o.CreatedDate}"/>
                
            </apex:pageBlockTable>
            <apex:panelGrid columns="7">
                <apex:commandButton status="fetchStatus" reRender="pb" value="|<" action="{!setCon.first}" disabled="{!!setCon.hasPrevious}" title="First Page"/>
                <apex:commandButton status="fetchStatus" reRender="pb" value="<" action="{!setCon.previous}" disabled="{!!setCon.hasPrevious}" title="Previous Page"/>
                <apex:commandButton status="fetchStatus" reRender="pb" value=">" action="{!setCon.next}" disabled="{!!setCon.hasNext}" title="Next Page"/>
                <apex:commandButton status="fetchStatus" reRender="pb" value=">|" action="{!setCon.last}" disabled="{!!setCon.hasNext}" title="Last Page"/>
                <apex:outputText >{!(setCon.pageNumber * size)+1-size}-{!IF((setCon.pageNumber * size)>noOfRecords, noOfRecords,(setCon.pageNumber * size))} of {!noOfRecords}</apex:outputText>
                <apex:commandButton status="fetchStatus" reRender="pb" value="Refresh" action="{!refresh}" title="Refresh Page"/>
                <apex:outputPanel style="color:#4AA02C;font-weight:bold">
                    <apex:actionStatus id="fetchStatus" startText="Fetching..." stopText=""/>
                </apex:outputPanel>
            </apex:panelGrid>
        </apex:pageBlock>
    </apex:form>
</apex:page>
Apex
 
public with sharing class Pagination_min {

    Public Integer noOfRecords{get; set;}
    Public Integer size{get;set;}
    public ApexPages.StandardSetController setCon {
        get{
            if(setCon == null){
                size = 500;
                string OwnersId =  userinfo.getUserId() ;
                string Rectypeid =   '01240000000Uexl';
                string Rectypeid2 = '01240000000cnJS';
                string queryString = 'Select Name, StageName,FED__c,Broker__c,Broker_Name__c,Core_Product__c,LeadSource,Number_Quoted__c,CreatedDate FROM Opportunity Where OwnerId = :OwnersId AND IsClosed = False AND (RecordTypeId = :Rectypeid OR RecordTypeId= :RecTypeId2) order by FED__c';
                setCon = new ApexPages.StandardSetController(Database.getQueryLocator(queryString));
                setCon.setPageSize(size);
                noOfRecords = setCon.getResultSize();
            }
            return setCon;
        }set;
    }
     
    Public List<Opportunity> getOpps(){
        List<Opportunity> oppList = new List<Opportunity>();
        for(Opportunity o : (List<Opportunity>)setCon.getRecords())
            oppList.add(o);
        return oppList;
    }
     
    public pageReference refresh() {
        setCon = null;
        getOpps();
        setCon.setPageNumber(1);
        return null; 
    }
}



 
trigger NoteOnContentDocument on ContentDocument (before delete) {
    for (ContentDocument c : Trigger.old){
        List<ContentDocumentLink> links = [
            SELECT LinkedEntityId 
            FROM ContentDocumentLink 
            WHERE ContentDocumentId= :c.Id
        ];
        if (Approval.isLocked(links.get(1).LinkedEntityId)){
            c.addError('Approval pending. You do not have the permission to delete this note, Please contact your administrator.');
           }    
    }
}

 
Hi,

Currently, I am using apex code to send an email to a specific user. I want to add the email in the activity history. Is there any way to add the emails to the activity history related list.
 
Messaging.EmailFileAttachment emailFileAttachment = new Messaging.EmailFileAttachment();
emailFileAttachment.setFileName(attachFile.Name);
emailFileAttachment.setBody(attachFile.Body);
emailFileAttachment.setContentType(attachFile.ContentType);
emailFileAttachment.setInline(false);
email.setSaveAsActivity(true);
email.setReplyTo(Label.From_Address);
email.setSubject('Application submitted documents ');
email.setHtmlBody('Test');
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { email });



Thanks,
Vijay
Account has a field `Source_System__c` as its parent.

I wanna query Name, Id from Source_System

This query is workable. 
[SELECT Source_System__r.Name, Source_System__r.Id from Account]

However, I wanna have the value from Source_System can be nested in a object.
Like the sub-query's result. But it didn't work.



    SELECT (SELECT Name, Id from Source_System) FROM Account
                             ^
ERROR at Row:1:Column:30
Didn't understand relationship 'Source_System' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.



    SELECT (SELECT Name, Id from Source_System__r) FROM Account
                             ^
ERROR at Row:1:Column:30
Didn't understand relationship 'Source_System__r' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
can i get many to many relation videos
how can we do query child from parent and parent from child?

Is it possible to do a SOQL query that allows me to obtain the SF Id of a master-detail custom field I have in a custom object?  I'm not wanting the ID for a record in the object I want the Id for the actual field.  Field API name is Opportunity__c in a custom object with an API name of Win_Form__c.

When someone takes the time/effort to repspond to your question, you should take the time/effort to either mark the question as "Solved", or post a Follow-Up with addtional information.  

 

That way people with a similar question can find the Solution without having to re-post the same question again and again. And the people who reply to your post know that the issue has been resolved and they can stop working on it.