• katrinaxx
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 1
    Replies
Here's the scenario:

When a user sets the Status of a Case to "Complete" and its previous Status is "New", I want it to be saved as "In Progress" first (for some trigger logic to run for "In Progress" Cases), before finally saving it as "Complete".  Is this possible?  Here's a snippet of code that I tried but it did not work:

if(originalStatus == 'New' || currentSR.OwnerId != Userinfo.getUserId()) {
             String holdOnToStatus = currentSR.Status;
             String holdOnToActionTaken = currentSR.ACTN_TAKEN_TXT__c;
            
             if(originalStatus == 'New') {
                 currentSR.Status = 'In Progress';
             }
             if(currentSR.OwnerId != Userinfo.getUserId()) {
                 currentSR.OwnerId = Userinfo.getUserId();
             }
             
             controller.save(); 
             //update currentSR;           // I also tried calling update instead of standard save but neither worked 
            
             currentSR.status = holdOnToStatus;
             currentSR.ACTN_TAKEN_TXT__c = holdOnToActionTaken;
}
controller.save(); 

Thanks!
I have a commandbutton within a VF page that invokes a controller method.  When I load the VF page in a subtab, the method gets called.  But when I load the VF page in a primary tab, the method is not getting called. 

Here is the code snippet in my Launcher VF Page that decides whether to open a Primary Tab or a Subtab in the Service Console:
       
        ...........

        var tabId;
        var resultId;
       
        //Callback function of getFocusedPrimaryTabId
        var showTabId = function showTabId(result) {
            tabId = result.id;
            //Open Search page as SUBTAB
            sforce.console.openSubtab(tabId, '/apex/ServiceRequestSearch?id=' + resultId, true, 'Service Request Search', null);
        };
       
        //Callback function of getFocusedPrimaryTabObjectId
        var getObjId = function getObjId(result) {
if(result.id != 'null'){
      resultId = result.id;
      sforce.console.getFocusedPrimaryTabId(showTabId);
               }
               else{
                    //Open Search page as PRIMARY TAB
                    sforce.console.openPrimaryTab(null, '/apex/ServiceRequestSearch?id=', true, 'Service Request Search')
            }
        };

Here is the command button that I have in the Search VF Page:

<apex:commandButton value="Search" action="{!doSearch}" rerender="resultBlock" status="searchStatus"/> 

And here's the doSearch method in the controller:

    public PageReference doSearch() {

     System.debug('METHOD START:  doSearch');
     List<String> caseIDList = new List<String>();
    
     //Compose dynamic SOSL query
     FindQuery =  'FIND\'' + SearchText + '\'IN ALL FIELDS RETURNING Case(Id, CaseNumber, ' +
         'Origin, Status, Priority, Subject, CreatedDate, Owner.Name, Division__c, Account.Name WHERE ';
               
        //Add Case Status in filter if a Status has been selected
        if (selectedStatus <> '--All--') {          
         FindQuery = FindQuery + ' and Status = \'' + selectedStatus + '\'';       
        } 
       
        //Add Case Priority in filter if a Priority has been selected
        if (selectedPriority <> '--All--'){          
         FindQuery = FindQuery + ' and Priority = \'' + selectedPriority + '\'';       
        }
       
        //Add Case Origin in filter if an Origin has been selected
        if (selectedOrigin <> '--All--'){          
         FindQuery = FindQuery + ' and Origin = \'' + selectedOrigin + '\'';       
        }
       
        //Search Results sorting logic
        //Sort by Created Date Descending
        if(selectedSorting == 'createDesc'){
         FindQuery = FindQuery + ' ORDER BY CreatedDate DESC)';
        }
        //Sort by Created Date Ascending
        else if(selectedSorting == 'createAsc'){
         FindQuery = FindQuery + ' ORDER BY CreatedDate ASC)';
        }
       
        try { 
            //Run SOSL Query
         List<List<SObject>> searchResultList = Search.query(FindQuery);
         caseList = ((List<Case>)searchResultList[0]);
        }
        catch(Exception ex) {
         System.debug('ERROR:' + ex);
        }
       
        return null;
    }

Map<String, Schema.SObjectType> gdMap = Schema.getGlobalDescribe();
Schema.Describesobjectresult dsr = gdMap.get('Account').getDescribe();
Map<String, Schema.SObjectField> fieldMap = dsr.fields.getMap();

 

if(testAccountObj.Name.containsAny(strCompare) {
}

 

Is there any way to code this such that the Name field is not hard coded? The requirement is to check ALL fields in the Account object and I don't want to have separate IF clauses for each field. Want it to be as dynamic as possible.  Is this even possible? 

 

Thanks!

I need to know if it's possible to retrieve some data from SFDC via jQuery.  I created a sample apex webservice to do this.  Then the webservice will be accessed from a 3rd party website via jQuery.  Problem is when it executes the processResponse() function, an exception is thrown because the xmlHttpRequest.responseXML is NULL.  What seems to be the problem?  =(

 

Here's the code of the webservice:  

global class TARetrieveArticlesWebService {
     WebService static String GetArticles()
     {
          In_Depth__c sampleData = [SELECT Name FROM In_Depth__c LIMIT 1];
          return sampleData.Name;
     }
}

 

And here's the code that I placed in the 3rd party site: 

<head>
     <script src='https://xxxxxxxx.full.cs1.force.com/SiteName/resource/jQuery_1_4_2' type='text/javascript'/>
</head>

 

<script type='text/javascript'>
var soapMessage = "<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><soap:Body><methodCall>GetArticles</methodCall></soap:Body></soap:Envelope>";

 

$.ajax({
     url: "http://xxxxxxxx.full.cs1.force.com/SiteName/services/Soap/class/TARetrieveArticlesWebService/GetArticles/",
     type: "POST",
     dataType: "xml",
     data: soapMessage,
     complete: processResponse,
     contentType: "text/xml; charset=\"utf-8\""
     });

 

function processResponse(xmlHttpRequest, status)
{
     $(xmlHttpRequest.responseXML).find('methodResponse').each(function()
     {
          var name = $(this).find('response').text();
          alert(name);
     });
}
</script>

Hi,

 

I have developped a apex trigger on FeedItem after insert.  The purpose is to append an hashtag to the body of the post when certain criteria are met.  Everything works very well except that any mention in the body of the post becomes plain text.  Existing hashtags and the one I append are treated like hashtags.  

 

The simplified code is as follows (it appends the tag to all posts and exhibits the problem):

 

trigger FeedItemTagger on FeedItem (before insert) {

          for (FeedItem fi : trigger.new) {

                  fi.body = fi.body + ' I added this #tag in my trigger.';

                  }

          }

 

 

 

Has anyone tried something like this before?  

 

Any ideas on how to prevent the @ mentions being converted into text.

 

Thanks
Derek

  • June 25, 2013
  • Like
  • 0