• lodoss1118
  • NEWBIE
  • 25 Points
  • Member since 2008

  • Chatter
    Feed
  • 1
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 13
    Questions
  • 16
    Replies

Hi I am trying to mimic how case milestones work with a custom object what i am trying to achieve is calculating the elapsed and remaining times.

When a new record is inserted it will calculate which business hour this record should be in. Now what i need to do is calculated the time in this business timezone.

 

For example record a is inserted and has new york time zone business hours i want to calculate the start time, end time in that timezone now what i also what is a real time count down of elapsed hours and remaining hours etc in that time zone. I also need to pause the time based on a status field.

 

So my question is this possible in a formula field? Any suggestions how to achieve this and salesfoce calculates when the time was paused?

 

for example I have this string LONG-08080-aSDDdd-001

how do I get the end of the string after the last "-" : note that 001 could also be 00000001, 0100000 etc.. so not only 3 chars long

How would i remove trailing zeroes (left after the first numeric char) for this 'LON00010'

Hi i am trying to get some values from the send email wizard form within my visualforce page:

 

 

<apex:page >
    
    <script>
        function GetFrameWindow(event)
        {
        	alert(event); 
        	var iFrame = document.getElementById(event);
        	alert(iFrame);
        	var oDoc = iFrame.contentDocument;
        	alert(oDoc);
        }
    </script>
    
    <apex:form >
        <apex:commandButton value="Check" onclick="GetFrameWindow('theIframe');"/>
        <apex:inputTextarea richText="true" cols="2" rows="2"/>
        <center>
            <apex:iframe id="theIframe" src="/_ui/core/email/author/EmailAuthor?p3_lkid=000000011111111&retURL=%2F01111111111111&template_id=1111111111111111&isdtp=mn" scrolling="true" frameborder="true" width="800" height="600"/>      
        </center>
    </apex:form>
  
</apex:page>

 but everytime i try to get something from oDoc it is always null?

 

 

hi i am trying create a formula field that calculates that expiry date from a start date and term

 

i got something like

 

startDate + terms * 30.4375

 

but it has some weird results? and does not handle leap years

 

anyone have a better formula :@

Hi i am not a perl expert and need some help in updating mass objects in one go for example

 

How would i building hash references say in a loop that builds a list of objects to update

 

and how would i pass this to the update method i.e. $sforce -> update(('type', $sObjectType), %locationObj);

 

so what i am after is how do i create a hash of hash references?

Hi i have object in salesforce that contains a city called Unterföhring it contains some weird character now when i do a sql on local db to find this city which it does contain Unterföhring i keep getting a no match.

 

$querySF = "SELECT Id, Name, Building_Name__c, Street__c, Building_Number__c, Postcode__c, City__c, Country__c, Building_Type__c, Building_Status__c, Building_Entry__c, Fibre_Access__c, POP_Type__c, Wayleave_Status__c ";
$querySF .= "FROM Location__c WHERE Active__c = true AND EXT_ID__c = null";

$resLocation = $sforce -> do_query($querySF, 2000);

foreach $location ( @{$resLocation} ) {

    $add = 1;
    $locationId = $location -> {'Id'}['Id'];

#print $locationId." ".$location -> {'Name'}." ".$location -> {'City__c'}."\n";

    # get tt city id
    
    $queryTT = "SELECT * FROM h_city WHERE name = '".$location -> {'City__c'}."'";
    $st = $db -> prepare($queryTT);
    $st -> execute;
    $row = $st -> fetchrow_hashref;
#    print $row -> {'h_city_id'}."\n";
    $cityID = $row -> {'h_city_id'};

    if ($row -> {'h_city_id'} < 1) {
        $add = 0;
    }

 

I am assuming that this is the problem   $queryTT = "SELECT * FROM h_city WHERE name = '".$location -> {'City__c'}."'"; it cannot match the name?

This is not my code and i am not a perl expert?

Hi guys i can't seem to get the hours and minutes to show in a datetime field in SFDC coming from an update from a java client app

 

        SimpleDateFormat timeStamp = new SimpleDateFormat("yyyy-MM-dd\'T\'HH:mm:ss");
        try {
            runRequest.setValue("Requested_Date__c", timeStamp.parse(timeStamp.format(new Date())));
        } catch (ParseException e) {
            System.out.println("Requested_Date__c Error : " + e.getCause());
        }

 

it updates the date time field but it never shows the hhmmss??

Hi i am making an application that will update the description/inline help text (Custom Field) from a CSV file.

 

Now i have done this in c# and got the basics worked out, the problem i am hitting is that when i convert the csv record into a Custom Field for update, i have to keep setting the type, which is of type enum FieldType and these values differ from describe fieldtypes and so creating a mapping table is out of the question.

 

Here is some code:

 

static void Main(string[] args)
        {
            SFDC_Enterprise.SforceService sv = new SFDC_Enterprise.SforceService();
            SFDC_Enterprise.LoginResult lr = sv.login("aaaa", "aaaaaaaaaaaaa");

            // set up a MetdataService client
            SFDC_Metadata.MetadataService ms = new SFDC_Metadata.MetadataService();
            ms.SessionHeaderValue = new SFDC_Metadata.SessionHeader();
            ms.SessionHeaderValue.sessionId = lr.sessionId;
            ms.Url = lr.metadataServerUrl; 

            Console.WriteLine("Logged in as {0}", lr.userInfo.userName); 

            FileHelperEngine engine = new FileHelperEngine(typeof(InlineHelpCSV));
            InlineHelpCSV[] helps = engine.ReadFile("InlineHelp.csv") as InlineHelpCSV[];
            List<SFDC_Metadata.CustomField> cfs = new List<SFDC_Metadata.CustomField>();

            /*SFDC_Metadata.CustomField cf = new SFDC_Metadata.CustomField();
            cf.fullName = "Service__c.Billing_End__c";
            cf.label = "Billing End";
            cf.type = SFDC_Metadata.FieldType.Date;
            cf.inlineHelpText = "Updated from WEB APP";

            SFDC_Metadata.UpdateMetadata mu = new SFDC_Metadata.UpdateMetadata();
            mu.metadata = cf; 
            mu.currentName = "Service__c.Billing_End__c";

            SFDC_Metadata.AsyncResult r = ms.update(new SFDC_Metadata.UpdateMetadata[] { mu })[0];
            int waitTimeMilliSecs = 1000;
          
            while (!r.done){
                System.Threading.Thread.Sleep(waitTimeMilliSecs);
                waitTimeMilliSecs *= 2;
                r = ms.checkStatus(new string[] { r.id })[0];
                Console.WriteLine("Status: {0}", r.state);
            }
            if (r.state == SFDC_Metadata.AsyncRequestState.Error){
                Console.WriteLine("Error : {0} {1}", r.statusCode, r.message);
            }else{
                Console.WriteLine("Done, updated inlinehelptext");
            }*/
            
            Console.WriteLine("Inlinetext updates found {0}", helps.Length);
            foreach (InlineHelpCSV a in helps)
            {
                Console.WriteLine(a.fullName + " - " + a.label + " - " + " - " + a.type + " - " + a.inlineHelpText);
                SFDC_Metadata.CustomField cf = new SFDC_Metadata.CustomField();
                cf.fullName = a.fullName;
                cf.label = a.label;
                //cf.type = 
                cf.inlineHelpText = a.inlineHelpText;
                cfs.Add(cf);
            }

            Console.ReadLine();
        }

 

So how i am supposed to dynamically get the metadata fieldtype enum?

 

 

public class ParamsController
{
    public String URL = 'https://na132222.salesforce.com/apex/params?na5.visualforce.devmode=1&resourceDate=asads0000jjaa-2010-09-24&mode=summary&resourceDate=as212343243a-2012-10-24&';
    
    public String foundParam{get{return GetParam(URL, 'resourceDate');} set;}
    
    public ParamsController(){
        List<String> params = GetParams(URL, 'resourceDate');
        System.debug('###params ###: ' + params);
    }
    
    public List<String> GetParams(string param){
        List<String> strList = new List<String>();
        String href = URL;
        if(href.indexOf('?') > -1){
            String qryStr = href.substring(href.indexOf('?')).replaceAll('\\?', '').toLowerCase();
            List<String> aQryStr = qryStr.split('&');
            for(Integer i = 0; i < aQryStr.size(); i++){
                String strCur = aQryStr[i].toLowerCase();
                String strMatch = strCur.substring(0, strCur.indexOf('=') + 1);
                if(((param + '=').toLowerCase() == strMatch)){
                    List<String> aParam = aQryStr[i].split('=');
                    strList.add(aParam[1]);
                }
            }
        }
        return strList; 
    }
    
    public List<String> GetParams(string url, string param){
        return GetParams(System.currentPageReference().getUrl(), param);
    }
    
    public String GetParam(string url, string param){
        String str = '';
        String href = URL;
        if(href.indexOf('?') > -1){
            String qryStr = href.substring(href.indexOf('?')).replaceAll('\\?', '').toLowerCase();
            List<String> aQryStr = qryStr.split('&');
            for(Integer i = 0; i < aQryStr.size(); i++){
                String strCur = aQryStr[i].toLowerCase();
                String strMatch = strCur.substring(0, strCur.indexOf('=') + 1);
                System.debug('###aQryStr ###: ' + strMatch);
                if(((param + '=').toLowerCase() == strMatch)){
                    List<String> aParam = aQryStr[i].split('=');
                    str = aParam[1];
                    break;
                }
            }
        }
        return str; 
    }
    
    public String GetParam(string param){
        return GetParam(System.currentPageReference().getUrl(), param);
    }    
}

 

 I keep getting this System.LimitException: Maximum stack depth reached: 193

 

i am wondering if the holiday object can be used to check is the current date is not that of a holiday and how would one go about it?

Hi is there anyway to keep a home page component on the left side if you move to another tab like accounts and contacts i got some javascript which i am assuming if the user is not on the home tab it will not work?

I have full experience in salesforce as an admin and developer using scontrols and apex can start immediately.

Please email me at lodoss118@gmail.com for cv.

for example I have this string LONG-08080-aSDDdd-001

how do I get the end of the string after the last "-" : note that 001 could also be 00000001, 0100000 etc.. so not only 3 chars long

hi i am trying create a formula field that calculates that expiry date from a start date and term

 

i got something like

 

startDate + terms * 30.4375

 

but it has some weird results? and does not handle leap years

 

anyone have a better formula :@

Hi i have object in salesforce that contains a city called Unterföhring it contains some weird character now when i do a sql on local db to find this city which it does contain Unterföhring i keep getting a no match.

 

$querySF = "SELECT Id, Name, Building_Name__c, Street__c, Building_Number__c, Postcode__c, City__c, Country__c, Building_Type__c, Building_Status__c, Building_Entry__c, Fibre_Access__c, POP_Type__c, Wayleave_Status__c ";
$querySF .= "FROM Location__c WHERE Active__c = true AND EXT_ID__c = null";

$resLocation = $sforce -> do_query($querySF, 2000);

foreach $location ( @{$resLocation} ) {

    $add = 1;
    $locationId = $location -> {'Id'}['Id'];

#print $locationId." ".$location -> {'Name'}." ".$location -> {'City__c'}."\n";

    # get tt city id
    
    $queryTT = "SELECT * FROM h_city WHERE name = '".$location -> {'City__c'}."'";
    $st = $db -> prepare($queryTT);
    $st -> execute;
    $row = $st -> fetchrow_hashref;
#    print $row -> {'h_city_id'}."\n";
    $cityID = $row -> {'h_city_id'};

    if ($row -> {'h_city_id'} < 1) {
        $add = 0;
    }

 

I am assuming that this is the problem   $queryTT = "SELECT * FROM h_city WHERE name = '".$location -> {'City__c'}."'"; it cannot match the name?

This is not my code and i am not a perl expert?

Hi guys i can't seem to get the hours and minutes to show in a datetime field in SFDC coming from an update from a java client app

 

        SimpleDateFormat timeStamp = new SimpleDateFormat("yyyy-MM-dd\'T\'HH:mm:ss");
        try {
            runRequest.setValue("Requested_Date__c", timeStamp.parse(timeStamp.format(new Date())));
        } catch (ParseException e) {
            System.out.println("Requested_Date__c Error : " + e.getCause());
        }

 

it updates the date time field but it never shows the hhmmss??

 

public class ParamsController
{
    public String URL = 'https://na132222.salesforce.com/apex/params?na5.visualforce.devmode=1&resourceDate=asads0000jjaa-2010-09-24&mode=summary&resourceDate=as212343243a-2012-10-24&';
    
    public String foundParam{get{return GetParam(URL, 'resourceDate');} set;}
    
    public ParamsController(){
        List<String> params = GetParams(URL, 'resourceDate');
        System.debug('###params ###: ' + params);
    }
    
    public List<String> GetParams(string param){
        List<String> strList = new List<String>();
        String href = URL;
        if(href.indexOf('?') > -1){
            String qryStr = href.substring(href.indexOf('?')).replaceAll('\\?', '').toLowerCase();
            List<String> aQryStr = qryStr.split('&');
            for(Integer i = 0; i < aQryStr.size(); i++){
                String strCur = aQryStr[i].toLowerCase();
                String strMatch = strCur.substring(0, strCur.indexOf('=') + 1);
                if(((param + '=').toLowerCase() == strMatch)){
                    List<String> aParam = aQryStr[i].split('=');
                    strList.add(aParam[1]);
                }
            }
        }
        return strList; 
    }
    
    public List<String> GetParams(string url, string param){
        return GetParams(System.currentPageReference().getUrl(), param);
    }
    
    public String GetParam(string url, string param){
        String str = '';
        String href = URL;
        if(href.indexOf('?') > -1){
            String qryStr = href.substring(href.indexOf('?')).replaceAll('\\?', '').toLowerCase();
            List<String> aQryStr = qryStr.split('&');
            for(Integer i = 0; i < aQryStr.size(); i++){
                String strCur = aQryStr[i].toLowerCase();
                String strMatch = strCur.substring(0, strCur.indexOf('=') + 1);
                System.debug('###aQryStr ###: ' + strMatch);
                if(((param + '=').toLowerCase() == strMatch)){
                    List<String> aParam = aQryStr[i].split('=');
                    str = aParam[1];
                    break;
                }
            }
        }
        return str; 
    }
    
    public String GetParam(string param){
        return GetParam(System.currentPageReference().getUrl(), param);
    }    
}

 

 I keep getting this System.LimitException: Maximum stack depth reached: 193

 

i am wondering if the holiday object can be used to check is the current date is not that of a holiday and how would one go about it?

Hi Friends,

 

I am new to salesforce. My requirement is that we are using our own LDAP authentication. Upon successful authentication it should redirect the user to salesforce free site url but before it hits free site URL I wanted to check in  the header URL to grab the HOST so that I can determine from where the request is coming from and if i found the reqest  is coming from valid HOST then i will let the user to see our free site page otherwise will show him the error page.

 

Note : We want to use salesforce free site.

 

Any suggestions would be really help full.

 

Thanks Guys!

 

  • August 24, 2010
  • Like
  • 0

I wrote the query:

 

Select count() from Account

 

I have around 20,000 accounts in the system.

So how am I suppouse to get their number in the system?

Thanks!

  • August 15, 2010
  • Like
  • 0

Hi is there anyway to keep a home page component on the left side if you move to another tab like accounts and contacts i got some javascript which i am assuming if the user is not on the home tab it will not work?

Hi guys i am trying to use the ajax toolkit in a homepage component, the problem is i have to login to get a session is there anyway i can do this without logging in. I have created an html area and added the following code:

 

 

<html>
<head>
	<script src="/soap/ajax/16.0/connection.js" type="text/javascript"></script>
	<script type="text/javascript">
		function ShowUser(){
		    //sforce.connection.login("**************8", "********");
			//sforce.connection.sessionId = '{!$Api.Session_ID}';
		    //var user = sforce.connection.getUserInfo();
			alert(document.cookie);
		}
		window.onload = ShowUser();
	</script>
</head>

<body>
</body>
</html>

 

But if i do not login it won't work?

I keep getting Too many SOQL Queries when I thought I wrote a bulk trigger until I did dataloader on update.. to get the porevious records.. Here is my code:

 

trigger bulktriggerfd on Placement__c (before insert,before update,after insert) { 
//Place the dataset in a Map to what is common in both objects 
//What would be the same through out the objects
Map<Id, Placement__c> PLAC = new Map<Id, Placement__c>();
for (Integer i = 0; i < Trigger.new.size(); i++) {
    if (System.Trigger.isInsert) {
        PLAC.put(Trigger.new[i].Participant__c,Trigger.new[i]); 
    }
    else if(System.Trigger.isUpdate){
        PLAC.put(Trigger.old[i].Participant__c,Trigger.new[i]);  
    }
}
//New List view 
List<Contact> updatedconField = new List<Contact>();
List<Placement__c> updatedplacField = new List<Placement__c>();

if(System.Trigger.isUpdate){
for (Contact c : [SELECT id,AccountId FROM Contact WHERE Id in :PLAC.keySet()]) {
        Placement__c parentAccount = PLAC.get(c.id);
        If(parentAccount.End_Date__c==null){
            c.AccountId = parentAccount.School__c;
            c.Current_Placement__c = parentAccount.Id;
            c.Current_Founder__c = parentAccount.Founder__c;
            c.Current_Program_City__c = parentAccount.Program_City__c;   
            c.Current_Role__c  = parentAccount.Role__c;  
            c.Current_Additional_Role_Info__c = parentAccount.Additional_Role_Info__c;
            c.Current_Weeks_Placed_in_Advance__c = parentAccount.Weeks_Placed_in_Advance__c;
            c.Current_Description__c   = parentAccount.Description__c; 
        }  
        if(parentAccount.End_Date__c!=null){
            List<Placement__c> pl = [Select id from Placement__c Where Id in :PLAC.keySet() and End_Date__c=null];
            if(pl.size()>0){
            c.AccountId = pl[0].School__c;
            c.Current_Placement__c = pl[0].Id;
            c.Current_Founder__c = pl[0].Founder__c;
            c.Current_Program_City__c = pl[0].Program_City__c;   
            c.Current_Role__c  = pl[0].Role__c;  
            c.Current_Additional_Role_Info__c = pl[0].Additional_Role_Info__c;
            c.Current_Weeks_Placed_in_Advance__c = pl[0].Weeks_Placed_in_Advance__c;
            c.Current_Description__c   = pl[0].Description__c; 
            }
            if(pl.size()==0){
            c.Current_Placement__c = null;
            c.Current_Program_City__c = null;   
            c.Current_Role__c  = null;  
            c.Current_Additional_Role_Info__c = null;
            c.Current_Weeks_Placed_in_Advance__c = null;
            c.Current_Description__c   = null;
            }
        }     
        System.Debug('parentAccount -  ' + parentAccount);
        
        updatedconField.add(c);
    }
    } 

if(System.Trigger.isInsert){
for (Contact c : [SELECT id,AccountId,Current_Placement__c FROM Contact WHERE Id in :PLAC.keySet()]) {
        Placement__c parentAccount = PLAC.get(c.id);
        If(parentAccount.End_Date__c==null){
            c.AccountId = parentAccount.School__c;
            c.Current_Placement__c = parentAccount.Id;
            c.Current_Founder__c = parentAccount.Founder__c;
            c.Current_Program_City__c = parentAccount.Program_City__c;   
            c.Current_Role__c  = parentAccount.Role__c;  
            c.Current_Additional_Role_Info__c = parentAccount.Additional_Role_Info__c;
            c.Current_Weeks_Placed_in_Advance__c = parentAccount.Weeks_Placed_in_Advance__c;
            c.Current_Description__c   = parentAccount.Description__c;             
            System.Debug('id = ' + parentAccount.Id);
        }
        System.Debug('parentAccountnew -  ' + parentAccount);
        
        updatedconField.add(c);
}
}    
    
    update updatedconField;
}

 

Thanks

 

Hi what i am trying achieve is to render a visualforce page to show only certain type of inputFields is this even possible. For example i want to determine something like which fields are empty and show only these fields in my custom visualforce page, i wish there was a dynamic visualforce component .