• Scott M - SFDC Fan
  • NEWBIE
  • 5 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 13
    Questions
  • 24
    Replies
Hi,

This is a general question. I'm not an experienced SF developer and I am running a test and it says I am trying to dereference a null object. I've set a checkpoint on the line under the line that is causing the error and from what I can tell, the object in question isn't null.

What else can I do to troubleshoot this?

Scott 

Hi,

I have an error screen in a flow, which is basically given to a user, when he or she tries to do something they shouldn't, like trying to do the edit workflow, when there is nothing to edit.

The problem is, in a flow screen that basically should end the flow, but isn't THE end of the flow, the "Next" button is still showing up and it allows the user to still continue on, when it really should just stop. Playing with the "Don't show Finish/Previous" buttons has no effect. I've added a connection back to the decision, so the next button just puts the user in a loop, but that isn't the best solution either.

How can I make a flow screen that is basically a proper "error" message and end the flow?

Hi,

Because of the new Lightning UI, the Javascript overlays I have are no longer going to work, because buttons that execute JS don't work in Lightning. The two types of overlays we have is one is a picture gallery to show attached pictures to cases or other objects. The other overlay works with flows to show different process wizards we've developed (even using Flows).

My question is, how can I reintroduce this kind of overlay functionality within Lightning? Without it, we will actually be going backwards with the usability, as the wizards are extremely important. I hope someone can give me a general tip or two on where to possible look for solutions.
Hi,

I am almost there. Despite SF visualflow's shortcomings with working with DateTime fields, I have a visual flow almost there where it sets up two dateTime fields called startDateTime and endDateTime. My problem is with calculating and saving a time, which works properly with the dataTime fields, because they always recalculate to GMT. 

What I am trying to accomplish is an Apex class, which recalls the user's timezone offset for two different times.

Here is the code.
 
public class UserTimezoneOffsets {

    public class inputVariables {
    
        @InvocableVariable(required=true)
        public DateTime startDateTime;
        @InvocableVariable(required=true)
        public DateTime endDateTime;
    }
    
    @InvocableMethod(
        label='Get user timezone offset' 
        description='Returns the users timezone offset in minutes for the given dates.')
    
    public static List<Integer> getOffsets (List<inputVariables> dateTimes ) 
    {
        TimeZone tz = UserInfo.getTimeZone();
        List<Integer> offsets = new List<Integer>();
        for (inputVariables dateTimeX : dateTimes) {
            offsets.add(tz.getOffset( dateTimeX.startDateTime ));        
            offsets.add(tz.getOffset( dateTimeX.endDateTime ));               
        }

        return offsets;  
    }

}

The issue is, how can I get the offsets back into the flow. 

Scott
Hi,

I am trying to create a page in sites.com, which will show up in the iframe right of the login to brand the login page. However, no matter what I do, the page errors, because Salesforce is blocking the content being shown in an iframe, despite the ClickJack setting for the site being set to "Allow framing by any page (no protection)".

Has anyone else created a page in Sites to use for the right side of the my domain login page? Would be rediculous, if this didn't work.

Scott
Hi,

I am admittedly a beginner and have somehow made a working class to support a visual force page with some logic. Now I need to move it to production, but have no idea how to make a test class for it. I hope someone can help. Here is the code.

public class Parts_Order_Extention {


    public static List<ProcessInstance> approval = Null;
    
    public Parts_Order_Extention(ApexPages.StandardController stdController){
        
        Parts_Orders__c partsOrder = (Parts_Orders__c)stdController.getRecord();
          
        approval = [SELECT ID,Status, TargetObjectID 
                    FROM ProcessInstance
                    WHERE TargetObjectID= :partsOrder.Id];
        
    }
        
    public String getGridName() {
        
       if (!approval.isEmpty() && approval[0].Status == 'Pending'){
         
           return 'Line Items RO';
           
       } else {
            
           return 'Line Items';
             
       }
     
    }

}

 

Hi,

 

I have a class that saves two case records per asset correctly. However, now the specification changed and the two cases must also relate to each other too, so when the user sees one case, they'll also see the related case in a related list. The original insert for the two cases per asset uses this code.

 

        if(!tmp_newCaseList.isEmpty())

        {

            Database.SaveResult[] tmp_saveResList = new Database.SaveResult[]{};

           

            try

            {

                tmp_saveResList = Database.insert(tmp_newCaseList, false);

            }

            catch(Exception e)

            {

                throw e;

            }

           

            if(tmp_saveResList != null && !tmp_saveResList.isEmpty())

            {

                for(Integer i = 0; i < tmp_saveResList.size(); i++)

                {

                    Database.SaveResult tmp_saveRes = tmp_saveResList.get(i);

                   

                    if(!tmp_saveRes.isSuccess())

                    {

                        String tmp_serialNo = tmp_newCaseList.get(i).Asset.SerialNumber;

                       

                        if(!a_failedNumbers.contains(tmp_serialNo))

                        {

                            a_failedNumbersMsg += tmp_serialNo + ', ';

                           

                            a_failedNumbers.add(tmp_serialNo);

                        }

                    }

                }

            }

           

            if(a_failedNumbersMsg != '')

            {

                a_failedNumbersMsg = a_failedNumbersMsg.substring(0, a_failedNumbersMsg.length() - 2);

            }

        }

       

        return Page.BulletinCaseResult;

    }

 

tmp_newCaseList is the list of cases.

 

Is there a relatively easy way to get the ID from one case of a certain asset and insert it into the other case created for that same asset using the tmp_saveResList to then update those cases?

 

Scott

Hi everyone,

 

I hate just throwing up code and saying "what's wrong with it?" but I am not an experienced programmer and I just can't find the issue. So I am hoping someone more experienced will find what is wrong. I am getting the "Argument 1 cannot be null" error from the following code. It is supposed to be an image viewer for images saved as case attachments (something I wish SF had standard BTW).

 

The funny thing is, the code below works on another object with a different page....so, go figure...

 

Here is the controller class

 

public class ImageViewController
{
    private final SObject so;
    private List<Photo> myPhotos = new List<Photo> ();
    
    
    public ImageViewController (ApexPages.StandardController controller)
    {
        this.so = controller.getRecord ();
        fetchPhotos ();
    }

    public class Photo
    {
        String id;
        String url;
        String name;
        
        public Photo (String ipId, String ipName)
        {
            id   = ipId;
            url  = '/servlet/servlet.FileDownload?file=' + id;  // This is the standard SFDC manner to "download" attachments.
            name = ipName;
        }
        
        public String getId ()
        {
            return id;
        }
        
        public String getUrl ()
        {
            return url;
        }
        
        public String getName ()
        {
            return name;
        }
        
    }

    private void fetchPhotos ()
    {
        myPhotos.clear ();  // Empty list
        
        for (Attachment a : [Select Id, Name, ContentType From Attachment Where ParentId = :so.Id])
        {   
            if (!a.Name.endsWith ('tif')) // Don't let TIFs get compared, as these can't be viewed by the viewer.
            {  
                if (a != null && (a.ContentType != '' || a.Id != '' || a.Name != '')) // If no data in the field, skip. 
                {
                    try
                    {
                        if (a.ContentType.contains ('image/'))  // Only add images except TIFs to the list, ignore all other types
                        {
                            myPhotos.add (new Photo (a.Id, a.Name));
                        }
                    } 
                    catch (Exception e)
                    {
                        ApexPages.addMessages(e);
                        Exception e1;
                        ApexPages.addMessages(e1);
                    }
                }
            }
        }
            
    }
                               
    public List<Photo> getPhotos ()
    {
        return myPhotos;
    }         
        
}

 

And this is the page

 

<apex:page standardController="Case" extensions="ImageViewController" showHeader="false" sidebar="false" standardStylesheets="false">
    
    <apex:styleSheet value="{!URLFOR($Resource.picbox,'picbox.css')}"/> 
    <apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"/> 
    <apex:includeScript value="{!URLFOR($Resource.picbox,'picbox.js')}"/>
    
    
          <script>
               if (!/android|iphone|ipod|series60|symbian|windows ce|blackberry/i.test(navigator.userAgent)) {
                    jQuery(function($) {
                        $("a[rel^='lightbox']").picbox({/* Put custom options here */}, null, function(el) {
                        return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
                        });
                    });
               }
               
         </script>        
  
           <apex:messages />

          <apex:repeat value="{!Photos}" var="p">
                <a rel="lightbox-viewer" href="{!p.url}"  title="{!p.name}" id="{!p.name}">
                     <img width="150" height="150" alt="{!p.name}" src="{!p.url}" title="{!p.name}" />
                </a>
              
           </apex:repeat>

      
</apex:page>
                

 Any help will be appreciated.

 

Regards,

 

Scott

Hi,

 

New to Apex and programming in Java in general here, so bear with me.

 

I have a junction object  set up CaseServiceOrderAssoc__c to connect cases to a custom object called Orders__c. The junction object is needed because I need a many to many relationship to orders and cases and this works great.  However, in the business process, we want to check to make sure all related cases to an order are closed, before I can also close the order.  I can create a roll-up summary field in Orders__c from CaseServiceOrderAssoc__c to do counting of open cases, but I need a trigger from the Case object to set the related junction object records to "true". This is what I've got as a trigger (through reading other solutions and piecing my solution from them.) Like I said, I have little experience with all this, so if the code is funny looking, you know why.

 

What am I doing wrong?

 

trigger updateCaseClosed on Case (after update) {
    
    // This trigger will update the closed case countable field in the Case 2 Order Association Object 
    
    Integer i = 0;
    Set<ID> CaseServiceOrderAssocIds = new Set<ID>();
    Map<ID, Boolean> id2CaseClosed = new Map<ID, Boolean>();
    
    for (Case c : Trigger.new)
    {
        if(c.IsClosed == True)
        {
            CaseServiceOrderAssocIds.add(c.Id);
            id2CaseClosed.put(c.Id, c.IsClosed);
        }
        i++;    
    } 
    List<CaseServiceOrderAssoc__c> c2oassocs = [select Id  from CaseServiceOrderAssoc__c where Id in :CaseServiceOrderAssocIds];
    
    for (CaseServiceOrderAssoc__c assocs : c2oassocs)
    {
        assocs.Related_Case_Closed_Countable__c = id2CaseClosed.get(assocs.Id);
    }
    
    update c2oassocs;
}
Hi, I am having troubles reading the forum/ board. Everything is centered. It seems like the CSS isn't getting through our proxy. Does anyone know what I can do to correct this? Thanks. Scott
Hi, Why would this simple JavaScript work in an S-Control and not in a VisualForce page? <script type="text/javascript" language="JScript"> var meldung = {!Case.SAP_Service_Notification__c} ; var command = '"*iw52 RIWO00-QMNUM=' + meldung + '"'; var sapuser ="{!$User.SAP_User_Name__c}"; var sprache="{!$User.SAP_Login_Language_New__c}"; var program = 'sapshcut.exe -sid=TDZ -clt=201 -user=' + sapuser + ' -command=' +command+ ' -language='+sprache+ ' -type=Transaction' ; function starte(program) { var WshShell = new ActiveXObject("WScript.Shell"); WshShell.Run(program); } </script> {!Case.SAP_Service_Notification__c} I get the following error: Details zum Fehler auf der Webseite Benutzer-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; .NET CLR 1.1.4322; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MS-RTC LM 8; .NET4.0C; .NET4.0E; MS-RTC LM 8) Zeitstempel: Mon, 30 May 2011 10:58:31 UTC Meldung: Automation server can't create object Zeile: 21 Zeichen: 3 Code: 0 URI: https://c.cs4.visual.force.com/servlet/servlet.Integration?lid=066P00000000BzW&ic=1 Meldung: Automation server can't create object Zeile: 21 Zeichen: 3 Code: 0 URI: https://c.cs4.visual.force.com/servlet/servlet.Integration?lid=066P00000000BzW&ic=1 Scott
Hi, What I mean is, is there a way to use the SF language system to show like field labels in a VisualForce page? Scott

Hi,

 

Is there a way to invoke a method of a controller extention, without connecting it to some sort of page element, like a button? I know about the action parameter in the page tag. However, I want to run some logic behind the scenes though, without the user pressing any buttons. For instance, saving something to the database, after the page is completely loaded.

 

Also, is there a way to pass a parameter to a method with the action parameter in the page tag?

 

Thanks for any assistance.

 

scamo

Hi,

This is a general question. I'm not an experienced SF developer and I am running a test and it says I am trying to dereference a null object. I've set a checkpoint on the line under the line that is causing the error and from what I can tell, the object in question isn't null.

What else can I do to troubleshoot this?

Scott 

Hi,

I have an error screen in a flow, which is basically given to a user, when he or she tries to do something they shouldn't, like trying to do the edit workflow, when there is nothing to edit.

The problem is, in a flow screen that basically should end the flow, but isn't THE end of the flow, the "Next" button is still showing up and it allows the user to still continue on, when it really should just stop. Playing with the "Don't show Finish/Previous" buttons has no effect. I've added a connection back to the decision, so the next button just puts the user in a loop, but that isn't the best solution either.

How can I make a flow screen that is basically a proper "error" message and end the flow?

Hi, I am having trouble with the "Attributes and Expressions" module from trailhead.

Here is the challenge:
Create a Lightning Component to display a single item for your packing list.
  • Create a component called campingListItem that displays the name (ui:outputText) and the three custom fields using the appropriate output components.
  • Add an attribute named 'item' for type Camping_Item__c.
I created an component named campingListItem and this is the code:
<aura:component >
    <aura:attribute name="item" type="<my_domain>__Camping_Item__c"/>
    
    <ui:outputText value="{!v.item.Name}"/>
    <ui:outputCheckbox value="{!v.item.<my_domain>__Packed__c}"/>
    <ui:outputCurrency  value="{!v.item.<my_domain>__Price__c}"/>
    <ui:outputNumber value="{!v.item.<my_domain>__Quantity__c}"/>
</aura:component>

The error that I am getting is: "Challenge Not yet complete... here's what's wrong: 
The packingListItem Lightning Component's attribute tag doesn't exist or its attributes are not set correctly."

With this, I tried to create another component, with the name "packingListItem", but It didn't work.

Can anyone help me?

Thanks,
I continue to have the problem that my VisualForce page Form does not pass onto my report's P2 filter the onchange="getComboA value selected on the form. The form passes on my calendar dates for P0 and P1 so this issue is specific to the GetCombo values not passing through correctly. Can someone please help me and suggest how I can tweak the Get Combo settings so this could pass through correctly?

   <apex:Page >
    <head>
        <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"/>
        <script src="//code.jquery.com/jquery-1.10.2.js"></script>
        <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
        <link rel="stylesheet" href="/resources/demos/style.css"/>
        <script>
            $(function() {
                $("#pv2").datepicker({changeMonth: true, changeYear: true});
                 $("#pv12").datepicker({changeMonth: true, changeYear: true});          
                $(".datepick").datepicker({changeMonth: true, changeYear: true, constrainInput: false});      
              });             
        </script>       
       <script>
           function getComboA(sel,inputId) {
                document.getElementById(inputId).value = sel.value;
            }
       </script>
    </head>
<TD>
                <form method="get" action="/00OE0000002ujMC" >           
                <B>New Confirmed/Travels (This Month)</B>
                <BR/>
                <b>Date Ranges:</b>
               <br/>
               Travel Date From (MM/DD/YYYY):
                <input type="text" name="pv0" id="pv0" class="datepick" /> <br/>
                Travel Date To (MM/DD/YYYY):
                <input type="text" name="pv1" id="pv1" class="datepick" />
                <br />
                Confirm Date (MM/DD/YYYY):
                <onchange="getComboA(pv2,'pv3')"/>
                
                <select name ="pv2" id="pv3" onchange="getComboA(pv2,'pv3')">
                    <option value="This Month">This Month</option>
                    <option value="Last Month">Last Month</option>
                    <option value="This Year">This Year</option>
                    <option value="Last Year">Last Year</option>
                    <option value="Today">Today</option>
                    <option value="Yesterday">Yesterday</option>
                    <option value="This Quarter">This Quarter</option>
                    <option value="Last Quarter">Last Quarter</option>
                     <option value="   ">Blank </option>
                </select><br/>
                <input type="submit" value="My Confirmed Travels" class="submit" />
                </form>
            </TD>


 
I have a flow that collects the date from one field, the time from a dropdown, and then uses a formula to combine the two to use to create an Event Record.

User-added image

I've used various combinations trying to get the formula to create something that can be used to populate the StartDateTime and the ActivityDateTime fields, but can't find a way to get it to work.

I have my choice stored values for time set to return miltary hours:minutes:seconds, e.g. 13:00:00

My current formula is: Text({!Tour_Date}) + " " + {!Tour_Time}

As a text formula this shows on my display text screen (that I'm using to verify my field inputs prior to using Record Create) as 2014-11-24 1:00PM, which seems to be as close as I can get as an input for the Event DateTime format.

But as soon as I change the formula value data type to DateTime, or if I add DATETIMEVALUE() around the formula above, my test sceen in the flow shows nothing for the result.

What am I missing?
Hi,

I am admittedly a beginner and have somehow made a working class to support a visual force page with some logic. Now I need to move it to production, but have no idea how to make a test class for it. I hope someone can help. Here is the code.

public class Parts_Order_Extention {


    public static List<ProcessInstance> approval = Null;
    
    public Parts_Order_Extention(ApexPages.StandardController stdController){
        
        Parts_Orders__c partsOrder = (Parts_Orders__c)stdController.getRecord();
          
        approval = [SELECT ID,Status, TargetObjectID 
                    FROM ProcessInstance
                    WHERE TargetObjectID= :partsOrder.Id];
        
    }
        
    public String getGridName() {
        
       if (!approval.isEmpty() && approval[0].Status == 'Pending'){
         
           return 'Line Items RO';
           
       } else {
            
           return 'Line Items';
             
       }
     
    }

}

 

Hi,

 

I have a class that saves two case records per asset correctly. However, now the specification changed and the two cases must also relate to each other too, so when the user sees one case, they'll also see the related case in a related list. The original insert for the two cases per asset uses this code.

 

        if(!tmp_newCaseList.isEmpty())

        {

            Database.SaveResult[] tmp_saveResList = new Database.SaveResult[]{};

           

            try

            {

                tmp_saveResList = Database.insert(tmp_newCaseList, false);

            }

            catch(Exception e)

            {

                throw e;

            }

           

            if(tmp_saveResList != null && !tmp_saveResList.isEmpty())

            {

                for(Integer i = 0; i < tmp_saveResList.size(); i++)

                {

                    Database.SaveResult tmp_saveRes = tmp_saveResList.get(i);

                   

                    if(!tmp_saveRes.isSuccess())

                    {

                        String tmp_serialNo = tmp_newCaseList.get(i).Asset.SerialNumber;

                       

                        if(!a_failedNumbers.contains(tmp_serialNo))

                        {

                            a_failedNumbersMsg += tmp_serialNo + ', ';

                           

                            a_failedNumbers.add(tmp_serialNo);

                        }

                    }

                }

            }

           

            if(a_failedNumbersMsg != '')

            {

                a_failedNumbersMsg = a_failedNumbersMsg.substring(0, a_failedNumbersMsg.length() - 2);

            }

        }

       

        return Page.BulletinCaseResult;

    }

 

tmp_newCaseList is the list of cases.

 

Is there a relatively easy way to get the ID from one case of a certain asset and insert it into the other case created for that same asset using the tmp_saveResList to then update those cases?

 

Scott

Hi everyone,

 

I hate just throwing up code and saying "what's wrong with it?" but I am not an experienced programmer and I just can't find the issue. So I am hoping someone more experienced will find what is wrong. I am getting the "Argument 1 cannot be null" error from the following code. It is supposed to be an image viewer for images saved as case attachments (something I wish SF had standard BTW).

 

The funny thing is, the code below works on another object with a different page....so, go figure...

 

Here is the controller class

 

public class ImageViewController
{
    private final SObject so;
    private List<Photo> myPhotos = new List<Photo> ();
    
    
    public ImageViewController (ApexPages.StandardController controller)
    {
        this.so = controller.getRecord ();
        fetchPhotos ();
    }

    public class Photo
    {
        String id;
        String url;
        String name;
        
        public Photo (String ipId, String ipName)
        {
            id   = ipId;
            url  = '/servlet/servlet.FileDownload?file=' + id;  // This is the standard SFDC manner to "download" attachments.
            name = ipName;
        }
        
        public String getId ()
        {
            return id;
        }
        
        public String getUrl ()
        {
            return url;
        }
        
        public String getName ()
        {
            return name;
        }
        
    }

    private void fetchPhotos ()
    {
        myPhotos.clear ();  // Empty list
        
        for (Attachment a : [Select Id, Name, ContentType From Attachment Where ParentId = :so.Id])
        {   
            if (!a.Name.endsWith ('tif')) // Don't let TIFs get compared, as these can't be viewed by the viewer.
            {  
                if (a != null && (a.ContentType != '' || a.Id != '' || a.Name != '')) // If no data in the field, skip. 
                {
                    try
                    {
                        if (a.ContentType.contains ('image/'))  // Only add images except TIFs to the list, ignore all other types
                        {
                            myPhotos.add (new Photo (a.Id, a.Name));
                        }
                    } 
                    catch (Exception e)
                    {
                        ApexPages.addMessages(e);
                        Exception e1;
                        ApexPages.addMessages(e1);
                    }
                }
            }
        }
            
    }
                               
    public List<Photo> getPhotos ()
    {
        return myPhotos;
    }         
        
}

 

And this is the page

 

<apex:page standardController="Case" extensions="ImageViewController" showHeader="false" sidebar="false" standardStylesheets="false">
    
    <apex:styleSheet value="{!URLFOR($Resource.picbox,'picbox.css')}"/> 
    <apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"/> 
    <apex:includeScript value="{!URLFOR($Resource.picbox,'picbox.js')}"/>
    
    
          <script>
               if (!/android|iphone|ipod|series60|symbian|windows ce|blackberry/i.test(navigator.userAgent)) {
                    jQuery(function($) {
                        $("a[rel^='lightbox']").picbox({/* Put custom options here */}, null, function(el) {
                        return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
                        });
                    });
               }
               
         </script>        
  
           <apex:messages />

          <apex:repeat value="{!Photos}" var="p">
                <a rel="lightbox-viewer" href="{!p.url}"  title="{!p.name}" id="{!p.name}">
                     <img width="150" height="150" alt="{!p.name}" src="{!p.url}" title="{!p.name}" />
                </a>
              
           </apex:repeat>

      
</apex:page>
                

 Any help will be appreciated.

 

Regards,

 

Scott

Please help!!  I have lost the salesforce lab app and can't get it back.  Is it coming back or am I completely out of luck?  This was the best thing for iPad yet

Hi,

 

New to Apex and programming in Java in general here, so bear with me.

 

I have a junction object  set up CaseServiceOrderAssoc__c to connect cases to a custom object called Orders__c. The junction object is needed because I need a many to many relationship to orders and cases and this works great.  However, in the business process, we want to check to make sure all related cases to an order are closed, before I can also close the order.  I can create a roll-up summary field in Orders__c from CaseServiceOrderAssoc__c to do counting of open cases, but I need a trigger from the Case object to set the related junction object records to "true". This is what I've got as a trigger (through reading other solutions and piecing my solution from them.) Like I said, I have little experience with all this, so if the code is funny looking, you know why.

 

What am I doing wrong?

 

trigger updateCaseClosed on Case (after update) {
    
    // This trigger will update the closed case countable field in the Case 2 Order Association Object 
    
    Integer i = 0;
    Set<ID> CaseServiceOrderAssocIds = new Set<ID>();
    Map<ID, Boolean> id2CaseClosed = new Map<ID, Boolean>();
    
    for (Case c : Trigger.new)
    {
        if(c.IsClosed == True)
        {
            CaseServiceOrderAssocIds.add(c.Id);
            id2CaseClosed.put(c.Id, c.IsClosed);
        }
        i++;    
    } 
    List<CaseServiceOrderAssoc__c> c2oassocs = [select Id  from CaseServiceOrderAssoc__c where Id in :CaseServiceOrderAssocIds];
    
    for (CaseServiceOrderAssoc__c assocs : c2oassocs)
    {
        assocs.Related_Case_Closed_Countable__c = id2CaseClosed.get(assocs.Id);
    }
    
    update c2oassocs;
}

I downloaded an app called Attachment Viewer that creates a Visualforce component to display images attached to a record.  The apex class uses a generic sObject so that it can be used on any any object by just modifying the VF page.

 

Our contacts have a lookup relationship to a custom object called Business Cards (contacts are the detail side of the relationship).

 

I would like to modify this code to look for attachments on the contacts business card parent record and display them on teh contact page, but I've never used generic sObjects in code before and am not sure how to modify it.

 

Basically the class should look for attachments where Parent in in :contact.business_card__c.id.  I tried to add this with no luck.

 

Here is the code I'm trying to modify.  Any idea how I can get this to work?

 

 

 

public class ImageViewController
{
    private final SObject so;
    private List<Photo> myPhotos = new List<Photo> ();
    
    public ImageViewController (ApexPages.StandardController controller)
    {
        this.so = controller.getRecord ();
        fetchPhotos ();
    }
    public class Photo
    {
        String id;
        String url;
        String name;
        
        public Photo (String ipId, String ipName)
        {
            id   = ipId;
            url  = '/servlet/servlet.FileDownload?file=' + id;  // This is the standard SFDC manner to "download" attachments.
            name = ipName;
        }
        
        public String getId ()
        {
            return id;
        }
        
        public String getUrl ()
        {
            return url;
        }
        
        public String getName ()
        {
            return name;
        }
    }
    private void fetchPhotos ()
    {
        myPhotos.clear ();  // Empty list
        
        for (Attachment a : [Select Id, Name, ContentType From Attachment Where ParentId = :so.Id])
        {
           // if (a.ContentType.startsWith ('image/'))  
            // Only add images to the list, ignore all other types
            {
                myPhotos.add (new Photo (a.Id, a.Name));
            }
        }
    }
                                   
    public List<Photo> getPhotos ()
    {
        return myPhotos;
    }             
}

 

 

Thanks you!!

Hi,

I have a formula field named Contract End Date and the value of this field should be calucated based on Contract Start Date and the Contract Duration. Contract Start Date is of type Date and Contract Duration is the number of months. Id I just add both the fields it considers Contract Duration as number of days instead of month. How do I achieve this?

Thanks
Jina