Search result for 'Apex'
(0.0258209705353 seconds)
Paulo Almeida/APEX ( SQL)
==============================================================================================================
Select & Denied list Implementatio
**************************************************************************************************************
PAGE ATTRIBUTES:
Display Attributes:
Cursor Focus: Do not focus cursor
HTML Header:
<script src="#WORKSPACE_IMAGES#select_text_dl.js" type="text/javascript"></script>
HTML Body Attribute:
onload="InitOnLoad('');"
onload="InitOnLoad('P1201_X_ADD_STAFF_NAME|P1201_STAFF_NAME|P1201_X_ADD_SITE|P1201_SITE|P1201_X_ADD_TYPE_OF_LEAVE|P1201_TYPE_OF_LEAVE');"
onload="InitOnLoad('P1001_TEXT_COUNTRY|P1001_COUNTRY|P1001_X_AREA|P1001_AREA|P1001_X_CAMP_NAME|P1001_CAMP_NAME|P1001_X_DFAC_ROWPU|P1001_DFAC_ROWPU_ICE_PLANT_ID|P1001_X_SUB_CONTRACTOR|P1001_SUB_CONTRACTOR|P1001_X_CITIZENSHIP|P1001_CITIZENSHIP|P1001_X_PLACE_OF_BIRTH|P1001_PLACE_OF_BIRTH|P1001_X_POSITION_TITLE|P1001_POSITION_TITLE|P1001_X_SHIFT|P1001_SHIFT|P1001_X_ADD_PHYSICIAN|P1001_PHYSICIAN|P1001_X_ADD_DEFICIENCY_DETAIL|P1001_DEFICIENCY_DETAIL');"
onload="InitOnLoad('P1101_X_ADD_CLASSIFICATION_TITLE|P1101_CLASSIFICATION_TITLE|P1101_X_ADD_PC_ELEMENT|P1101_PC_ELEMENT|P1101_X_ADD_SITE|P1101_SITE|P1101_X_ADD_PAYROLL|P1101_PAYROLL|P1101_X_ADD_PERSONNEL_AREA|P1101_PERSONNEL_AREA|P1101_X_ADD_CLASS_CODE|P1101_CLASS_CODE|P1101_X_ADD_SALARY_CHANGE_REASON|P1101_SALARY_CHANGE_REASON|P1101_X_ADD_EMPLOYEE_TYPE|P1101_EMPLOYEE_TYPE');"
onload="InitOnLoad('P1001_AREA_TEXT|P1001_AREA|P1001_LOCAREA_TEXT|P1001_LOCAREA|P1001_SITE_TEXT|P1001_SITE|P1001_H_TYPE_TEXT|P1001_H_TYPE');"
onload="InitOnLoad('P1301_SUB_CONTRACTOR_TEXT|P1301_SUB_CONTRACTOR|P1301_JOB_TITLE_TEXT|P1301_JOB_TITLE|P1301_AREA_TEXT|P1301_AREA|P1301_SITE_TEXT|P1301_SITE|P1301_INCIDENT_TYPE_TEXT|P1301_INCIDENT_TYPE|P1301_BY_WHOM_TEXT|P1301_BY_WHOM|P1301_FACILITY_TEXT|P1301_FACILITY|P1301_STATUS_TEXT|P1301_STATUS|P1301_EXPECTED_TRANSFER_DESTINATION_TEXT|P1301_EXPECTED_TRANSFER_DESTINATION|P1301_FACILITY_2_TEXT|P1301_FACILITY_2|P1301_STATUS_2_TEXT|P1301_STATUS_2|P1301_EXPECTED_TRANSFER_DESTINATION2_TEXT|P1301_EXPECTED_TRANSFER_DESTINATION_2|P1301_FACILITY_3_TEXT|P1301_FACILITY_3|P1301_STATUS_3_TEXT|P1301_STATUS_3|P1301_EXPECTED_TRANSFER_DESTINATION3_TEXT|P1301_EXPECTED_TRANSFER_DESTINATION_3|P1301_FACILITY_4_TEXT|P1301_FACILITY_4|P1301_STATUS_4_TEXT|P1301_STATUS_4|P1301_EXPECTED_TRANSFER_DESTINATION4_TEXT|P1301_EXPECTED_TRANSFER_DESTINATION_4|P1301_FACILITY_5_TEXT|P1301_FACILITY_5|P1301_STATUS_5_TEXT|P1301_STATUS_5|P1301_EXPECTED_TRANSFER_DESTINATION5_TEXT|P1301_EXPECTED_TRANSFER_DESTINATION_5|P1301_FACILITY_6_TEXT|P1301_FACILITY_6|P1301_STATUS_6_TEXT|P1301_STATUS_6|P1301_EXPECTED_TRANSFER_DESTINATION6_TEXT|P1301_EXPECTED_TRANSFER_DESTINATION_6|P1301_FACILITY_7_TEXT|P1301_FACILITY_7|P1301_STATUS_7_TEXT|P1301_STATUS_7|P1301_EXPECTED_TRANSFER_DESTINATION7_TEXT|P1301_EXPECTED_TRANSFER_DESTINATION_7|P1301_DISPOSITION_TEXT|P1301_DISPOSITION');"
SELECT LIST:
Source
source Used: Always...
Source Type: Item...
Source value or expression: Nome do TEXT FIELD correspondente
TEXT:
Element: style="width: 200px;background-color:#FFFFCC;"
==============================================================================================================
USING Checkboxes
**************************************************************************************************************
select APEX_ITEM.CHECKBOX(1,"SEC_ROLE"."SRO_ROLE_ID") " ", "SRO_ROLE_ID","SRO_ROLE_NAME","SRO_DESCRIPTION" WHERE SRO_DELETED_DATE IS NULL ORDER BY SRO_ROLE_NAME
==============================================================================================================
PL/SQL RETURNING FUNCTION INVERTION
**************************************************************************************************************
NOT(PKG_TOOLS.FUNC_IS_DUPLICATED ('SEC_OBJECT', 'SOB_OBJECT_NAME', :P4_SOB_OBJECT_NAME));
==============================================================================================================
GETTING USERNAME
**************************************************************************************************************
HTMLDB_UTIL.GET_USERNAME(HTMLDB_UTIL.GET_CURRENT_USER_ID)
OR
APEX_UTIL.GET_USERNAME(APEX_UTIL.GET_CURRENT_USER_ID)
OR
APEX_CUSTOM_AUTH.GET_USERNAME
OR
SELECT NVL(v('APP_USER'), USER) FROM DUAL
OR
V_USER_NAME := UPPER(NVL(v('APP_USER'), USER));
==============================================================================================================
GETTING APEX INTERACTIVE REPORT ATTRIBUTES TABLE
**************************************************************************************************************
SELECT * FROM FLOWS_030100.APEX_APPLICATION_PAGE_IR_RPT WHERE APPLICATION_ID = 151 AND PAGE_ID = 1000
SELECT WSC.REPORT_LABEL, WSC.DB_COLUMN_NAME
FROM FLOWS_030100.WWV_FLOW_WORKSHEETS WS, FLOWS_030100.WWV_FLOW_WORKSHEET_COLUMNS WSC
WHERE sql_query like '%HOURS_AND_MILEAGE%' AND WS.ID = WSC.WORKSHEET_ID
ORDER BY wsc.page_id, WSC.DISPLAY_ORDER
==============================================================================================================
JAVASCRIPT NA PÁGINA
**************************************************************************************************************
<script language="JavaScript" type="text/javascript">
<!--
htmldb_delete_message='"DELETE_CONFIRM_MSG"';
//-->
</script>
==============================================================================================================
JAVASCRIPT NO BOTÃO
**************************************************************************************************************
javascript:confirmDelete(htmldb_delete_message,'DELETE_ALL_CHECKED');
==============================================================================================================
Validations ROLE - SEC_CRED_X_ROLE_DEPENDENCY
**************************************************************************************************************
DECLARE
M_COUNT INTEGER :=0;
B_RET BOOLEAN := TRUE;
BEGIN
FOR I IN 1..APEX_APPLICATION.G_F01.COUNT LOOP
SELECT COUNT(*) INTO M_COUNT from SEC_CRED_X_ROLE WHERE SCRL_DELETED_DATE IS NULL AND SRO_ROLE_ID = TO_NUMBER(APEX_APPLICATION.G_F01(I));
IF M_COUNT > 0 THEN
B_RET := FALSE;
EXIT;
END IF;
END LOOP;
RETURN B_RET;
END;
==============================================================================================================
LOGIC_DELETION
**************************************************************************************************************
FOR I IN 1..APEX_APPLICATION.G_F01.COUNT LOOP
UPDATE SEC_ROLE SET SRO_DELETED_BY = APEX_CUSTOM_AUTH.GET_USERNAME, SRO_DELETED_DATE = SYSDATE WHERE SRO_ROLE_ID = APEX_APPLICATION.G_F01(I);
END LOOP;
or
FOR I IN 1..APEX_APPLICATION.G_F01.COUNT LOOP
UPDATE HSE_DFAC_AREA SET DELETED = 1 WHERE RECORD_ID = APEX_APPLICATION.G_F01(I);
END LOOP;
APEX - Snipets
abhinavguptas/Apex Controller for Javascript Remoting Sample ( Java)
public global with sharing class testremotingcontroller {
@RemoteAction
global static Account[] searchAccounts(String accountName) {
// Search accounts for the account name passed from Javascript
accountName = accountName.replaceAll('[*]', '%');
return [select id, name, phone, type, numberofemployees from
Account where name like :accountName ];
}
@RemoteAction
global static boolean updateAccount(String accountId, String phoneNum) {
// update account for the accountId and phone-number passed from Javascript
update new Account(Id = accountId, Phone = phoneNum);
return true;
}
}
The matching visualforce page code can be found here : http://snipplr.com/view/51124/editable-account-grid-using-visualforce-javascript-remoting--jquery-templates/
abhinavguptas/Apex Controller for Action Region Demo VF Page ( C#)
public class regioncontroller {
public String name { get; set; }
public String job { get; set; }
}
abhinavguptas/Batch Apex Database.Batchable AggregateResult via Iterable ( C#)
global class IterableAggregator implements Database.Batchable<AggregateResult> {
global Iterable<AggregateResult> start(Database.batchableContext info){
// just instantiate the new iterable here and return
return new AggregateResultIterable();
}
global void execute(Database.BatchableContext BC, List<Sobject> scope){
System.debug('SCOPE > ' + scope);
}
global void finish(Database.BatchableContext BC){
}
global class AggregateResultIterable implements Iterable<AggregateResult> {
global Iterator<AggregateResult> Iterator(){
return new AggregateResultIterator();
}
}
global class AggregateResultIterator implements Iterator<AggregateResult> {
AggregateResult [] results {get;set;}
Integer index {get; set;}
global AggregateResultIterator() {
index = 0;
String query = 'Select Department, COUNT(Name) From Contact GROUP BY Department';
results = Database.query(query);
}
global boolean hasNext(){
return results != null && !results.isEmpty() && index < results.size();
}
global AggregateResult next(){
return results[index++];
}
}
}
henry5/Get page parameters ( Java)
ApexPages.currentPage().getParameters.get('parameter_name')
Get page parameters (GET)
d3developer/@fractastical jQuery Dialog VF Page ( Other)
<div id="addTask" style="display: none" >
<apex:outputpanel id="atd">
<h2>New Task</h2>
<apex:form >
<apex:panelGrid columns="2" width="85%">
<apex:outputLabel value="Name"/><apex:inputText value="{!newTask.name}" size="21" />
<apex:outputLabel value="Description"/><apex:inputField value="{!newTask.Description__c}" />
<apex:outputLabel value="Assign to"/>
<apex:inputField value="{!newTask.Assigned_To__c}" />
<apex:commandButton action="{!addNewTask}"
oncomplete="$('#addTask').dialog('close')" value="Create this Task" rerender="recordsection,msgs" />
<apex:commandButton value="Cancel" immediate="true"
oncomplete="$('#addTask').dialog('close')"/>
</apex:panelGrid>
</apex:form>
</apex:outputpanel>
</div> <!-- addTask -->
***
<script type="text/javascript">
$(function(){
$("#addTask").dialog({
autoOpen: false,
modal: true,
closeable: false,
resizable: false,
width: 600
});
});
</script>
d3developer/@jeffdonthemic apex:datatable ( Other)
<apex:dataTable value="{!accounts}" var="account" id="theTable">
<apex:facet name="caption">table caption</apex:facet>
<apex:facet name="header">table header</apex:facet>
<apex:facet name="footer">table footer</apex:facet>
<apex:column>
<apex:facet name="header">Name</apex:facet>
<apex:facet name="footer">column footer</apex:facet>
<apex:outputText value="{!account.name}"/>
</apex:column>
<apex:column>
<apex:facet name="header">Owner</apex:facet>
<apex:facet name="footer">column footer</apex:facet>
<apex:outputText value="{!account.owner.name}"/>
</apex:column>
</apex:dataTable>
d3developer/@jeffdonthemic apex:datalist ( Other)
<apex:dataList value="{!accounts}" var="account" id="theList">
<apex:outputText value="{!account.name}"/>
</apex:dataList>
atik97/Center OF Gravity OF Triangle From Apex ( Python)
def cg():
sum_x=0
sum_y=0
for i in range(3):
print "Enter Coordinate OF Apex %s"%(i+1)
x=input("Enter x:")
y=input("Enter y:")
sum_x += x
sum_y += y
x=sum_x/3.0
y=sum_y/3.0
print "The Coordinate OF Center OF Gravity is (%s,%s)"%(x,y)
This will find the center of gravity of the triangle from the apex.
leeclint/Reassign Leads in Salesforce - APEX language ( Java)
global class LeadReassignOnActivityHistory implements Database.Batchable<sObject>{
private Date reassignDate = System.Today() - 10; // Sets the cutoff period on which you want to protect Leads
global Iterable<sObject> start(Database.BatchableContext BC) {
// This set will hold the Id's of the Leads that we will reassign.
Set <ID> LeadIds = new Set <ID>();
// Query all the Leads in your database and sub-query all existing Activities that match your criteria (i.e. Type), and return the newest one.
List <Lead> startLeads = new List <Lead>([Select (Select WhoId, ActivityDate FROM ActivityHistories WHERE ActivityType='Call' OR ActivityType='Ownership Transferred' ORDER BY ActivityDate DESC Limit 1) FROM Lead]);
// Iterate through the list of leads returned above.
for (Lead l : startLeads) {
// if the Lead does not have any Activities associated with it then reassign it.
if (l.ActivityHistories.size() == 0 || l.ActivityHistories.size() == null) {
LeadIds.add(l.Id);
}
//for each lead, iterate through its related Activities
for (ActivityHistory activity : l.ActivityHistories) {
// if the Activity is older than the reassignDate variable you set above, then this lead's ID will be added to the list that will be reassigned.
if (activity.ActivityDate < reassignDate) {
LeadIds.add(activity.WhoId);
}
} // close inner for-loop
} //close outer for-loop
// Using the list of ID's above, query the database for all related leads and get the necessary fields.
List <Lead> leadsToReassign = new List <Lead>([Select Id, Location__c, OwnerId FROM Lead WHERE Id IN :LeadIds]);
// Return this list of leads, which will get passed to our execute() method below.
return leadsToReassign;
} //close start method
global void execute(Database.BatchableContext BC, List <Lead> scope) {
// This list of tasks will be used to hold tasks for insert.
List <Task> taskList = new List<Task>();
// Iterate through the scope of Leads that were passed through to the execute method and transfer ownership based on the location.
// This example only has two locations.
// Create a Task that's associated with each Lead, this can be used so that we don't reassign the same Lead every day if no activity is being logged.
for(Lead l : scope) {
if(l.Location__c == 'Location A') {
l.OwnerId = '005A0000000i84o'; // reassigns ownership via hardcoded Id
Task tsk = new Task(); // Create the new task and populate it with data.
tsk.WhoId = l.Id;
tsk.ActivityDate = System.today();
tsk.Status = 'Completed';
tsk.Subject = 'Ownership Transferred';
tsk.Type = 'Other';
taskList.add(tsk); // add the task to the list.
} //close if statement
else {
l.OwnerId='005A0000000i84z';
Task tsk = new Task();
tsk.WhoId = l.Id;
tsk.ActivityDate = System.today();
tsk.Status = 'Completed';
tsk.Subject = 'Ownership Transferred';
tsk.Type='Other';
taskList.add(tsk);
} //close else
} //close for-loop
try {
insert taskList;
} catch (system.dmlexception e) {
System.debug('Tasks not inserted: ' + e);
}
try {
update scope;
} catch (system.dmlexception e) {
System.debug('Scope not updated: ' + e);
}
} //close execute method
global void finish(Database.BatchableContext BC) {
AsyncApexJob a = [Select Id, Status, NumberOfErrors, JobItemsProcessed,
TotalJobItems, CreatedBy.Email
from AsyncApexJob where Id =
:BC.getJobId()];
// Create and send an email with the results of the batch.
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setToAddresses(new String[] {a.CreatedBy.Email});
mail.setReplyTo('yourname@yourdomain.com');
mail.setSenderDisplayName('Lead Reassignment Results');
mail.setSubject('Lead Reassignment ' + a.Status);
mail.setPlainTextBody('The batch apex job processed ' + a.TotalJobItems +
' batches with ' + a.NumberofErrors + ' failures.');
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
} //close finish method
} //close class
Batch Apex class that allows you to reassign leads based on ActivityHistory.
Xhitman/Visualforce and Apex to Populate PDF Forms ( Other)
private String getXmlString(Contact c)
{
String s = '<?xml version="1.0" encoding="UTF-8"?>' +
'<xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">' +
'<f href="http://mysites-developer-edition.na1.force.com/resource/0/myform.pdf"/>' +
'<fields>' +
'<field name="DOB"><value>' + c.birthdate + '</value></field>' +
'<field name="Name"><value>' + c.firstname + ' ' + c.lastname + '</value></field>' +
'<field name="SS"><value>' + c.SS_Number__c + '</value></field>' +
'<field name="Phone"><value>' + c.phone + '</value></field>' +
'<field name="Citizenship"><value>' + c.Citizenship__c + '</value></field>' +
'<field name="CountryOfBirth"><value>' + c.Country_of_Birth__c + '</value></field>' +
'<field name="Tax"><value>' + c.Country_of_Tax_Residence__c + '</value></field>' +
'<field name="GovId"><value>' + c.Government_Identification__c + '</value></field>' +
'<field name="IdNumber"><value>' + c.ID_Number__c + '</value></field>' +
'</fields><ids original="FEBDB19E0CD32274C16CE13DCF244AD2" modified="5BE74DD4F607B7409DC03D600E466E12"/>' +
'</xfdf>';
return s;
}
public PageReference XFDFInit() {
Contact c = [SELECT Id, firstname, lastname, SS_Number__c, birthdate,
phone, Citizenship__c,
Country_of_Birth__c, Country_of_Tax_Residence__c,
Government_Identification__c, ID_Number__c,
Account.Name, Account.BillingStreet, Account.BillingCity,
Account.BillingState, Account.BillingPostalCode
FROM Contact
WHERE id = :ApexPages.currentPage().getParameters().get('id')];
String xmlContent = getXmlString(c);
Attachment attachment = new Attachment();
attachment.Body = Blob.valueOf(xmlContent);
attachment.Name = c.lastname + c.firstname + '.XFDF';
attachment.ParentId = c.Id;
insert attachment;
PageReference contactPage = new PageReference('/' + c.id);
contactPage.setRedirect(true);
return contactPage;
}
<apex:page showHeader="true"
controller="myXFDFController"
action="{!XFDFInit}"
showHeader="false">
</apex:page>
Credits to Jesse Lorenz http://wiki.developerforce.com/index.php/Adobe_XFDF
Mike Eaton/Salesforce.com - Apex code to Clone an Object ( Salesforce - Apex)
Opportunity opp=[select Id,Name from opportunity where id='XXXX000003Relo']; Opportunity newOpp = opp.clone(false, true); newOpp.Name=opp.Name + ' CLONE'; insert newOpp;
Clones an existing object and inserts it back to the database. (Salesforce, Apex)
Mike Fullmore/Bulk Trigger Example ( Salesforce - Apex)
tirgger MyTriggerName on SObject(before insert, before update){
Set<Id> sobjectSetOfIds = new Set<Id>();
//then interate through your SObjects
for(SObject s : trigger.new){
if(s.idField != null){
sobjectSetOfIds.add(s.idField);
}
}
Map<Id,SObject> sobjectMap = new Map<Id,SObject>([select Id, [ALL_OTHER_FIELDS] from SObject where Id in : sobjectSetOfIds]);
for(SObject s : trigger.new){
if(sobjectMap.containsKey(s.idField)){
s.fieldToUpdate = sobjectMap.get(s.idField).field;
}
}
}
To be successful with Apex code you need to think in bulk operation. Here is an example for you to follow to get your feet wet.
Mike Eaton/Generate a comma separate Object Field list ( Salesforce - Apex)
public static String f(String so) {
Integer i;
String f;
SObjectType sot = Schema.getGlobalDescribe().get(so);
if (sot == null) return null;
List<Schema.SObjectField> fields = sot.getDescribe().fields.getMap().values();
f = fields[0].getDescribe().LocalName;
for (i = 1; i < fields.size(); i++)
f += ',' + fields[i].getDescribe().LocalName;
return f;
}
Salesforce.com Apex code used to retrieve a comma separated list of fields for a particular Object. Handy for creating dynamic SOQL of all fields in a particular object.
Tim Mays/Class config using custom settings ( Salesforce - Apex)
public class MyClass {
private final Map<String, MyClassConfig__c> configMap = MyClassConfig__c.getAll();
public String foo {
get {
return configMap.get('myFooConfigItem').field__c;
}
}
public String bar {
get {
return configMap.get('myBarConfigItem').field__c;
}
}
}
Expose a list type custom setting with a class member.