|
23 | 23 |
|
24 | 24 | <body class="hljs">
|
25 | 25 | <pre><code class="language-apex">
|
26 |
| - List<SObject> mylist = [SELECT Name, StreetAddress__c, COUNT(), |
27 |
| - (SELECT Id FROM Contacts) |
28 |
| - FROM Warehouse__c.Contacts__r |
29 |
| - WHERE DISTANCE(Location__c, GEOLOCATION(37.775,-122.418), 'mi') < 20 |
30 |
| - AND Date__kav NOT IN LAST_N_DAYS:80 |
31 |
| - ORDER BY DISTANCE(Location__c, GEOLOCATION(37.775,-122.418), 'mi') |
32 |
| - LIMIT 10]; |
| 26 | + |
33 | 27 |
|
34 | 28 | delete myAccount;
|
35 | 29 | Account a;
|
|
42 | 36 |
|
43 | 37 | List<Opportunity> opps = [SELECT Id FROM Opportunity WHERE Id NOT IN :newRecordsMap.keySet()];
|
44 | 38 |
|
45 |
| - String queryText = 'SELECT Id, Name, AccountId, FirstName, LastName, mailingstreet, mailingcity, mailingstate, mailingpostalcode, mailingcountry, ' + |
46 |
| - 'otherstreet, othercity, otherstate, otherpostalcode, othercountry, mailinglatitude, mailinglongitude, otherlatitude, otherlongitude ' + |
47 |
| - 'FROM Contact WHERE AccountId = :acctid ORDER BY ' + |
48 |
| - String.escapeSingleQuotes(SortFullExp) + |
49 |
| - ' NULLS LAST LIMIT 1000'; |
50 |
| - String queryText = 'SELECT Id, Name, AccountId, FirstName, LastName, mailingstreet, mailingcity, mailingstate, mailingpostalcode, mailingcountry, ' |
| 39 | + |
| 40 | + String queryText = 'SELECT Id, Name, '; |
| 41 | + acctid = System.currentPageReference().getParameters().get('Id'); |
| 42 | + System.assert(true); |
| 43 | + System.requestVersion(); |
51 | 44 | </code></pre>
|
52 |
| - <p>-------NEW LANGUAGE----------</p> |
| 45 | + <p>-------NEW_CODEBLOCK----------</p> |
53 | 46 | <pre><code class="language-apex">
|
54 | 47 | @IsTest
|
55 | 48 | private without sharing class myTestClass {
|
56 | 49 | myMap?.get('Id');
|
57 | 50 | }
|
58 | 51 | System.URL.getCurrentRequestUrl();
|
59 |
| - System.getCurrentRequestUrl(); |
| 52 | + URL.getCurrentRequestUrl(); |
60 | 53 |
|
61 | 54 | public List<SelectOption> recordTypes { get; private set; }
|
62 | 55 | </code></pre>
|
63 |
| - <p>-------NEW LANGUAGE----------</p> |
| 56 | + <p>-------NEW_CODEBLOCK----------</p> |
64 | 57 | <pre><code class="language-apex">
|
65 | 58 |
|
66 | 59 | Database.insert(myAccounts, false, AccessLevel.USER_MODE);
|
67 | 60 | delete myAccount;
|
68 | 61 | delete [SELECT Id FROM Account];
|
| 62 | + myAcct = (Account)myacct; |
69 | 63 |
|
70 | 64 | public String myString { get; set; }
|
71 | 65 |
|
|
78 | 72 | @throws DMLException
|
79 | 73 | */
|
80 | 74 |
|
| 75 | + List<SObject> mylist = [SELECT Name, StreetAddress__c, COUNT(), |
| 76 | + (SELECT Id FROM Contacts) |
| 77 | + FROM Warehouse__c.Contacts__r |
| 78 | + WHERE DISTANCE(Location__c, GEOLOCATION(37.775,-122.418), 'mi') < 20 |
| 79 | + AND Date__kav NOT IN LAST_N_DAYS:80 |
| 80 | + ORDER BY DISTANCE(Location__c, GEOLOCATION(37.775,-122.418), 'mi') |
| 81 | + LIMIT 10]; |
| 82 | + |
| 83 | + String queryText = 'SELECT Id, Name, AccountId, FirstName, LastName, mailingcountry, ' + |
| 84 | + 'FROM Contact WHERE AccountId = :acctid ORDER BY ' + |
| 85 | + String.escapeSingleQuotes(SortFullExp) + |
| 86 | + ' NULLS LAST LIMIT 1000'; |
| 87 | + |
81 | 88 | /**
|
82 | 89 | * @author {@link [David Schach](https://github.com/dschach)}
|
83 | 90 | * @group Visualforce
|
|
87 | 94 |
|
88 | 95 | public enum Season {WINTER, SPRING, SUMMER, FALL}
|
89 | 96 |
|
90 |
| - /** |
91 |
| - * Extension Constructor |
92 |
| - * @param stdController `ActionPlan__c` Standard Controller |
93 |
| - */ |
94 | 97 | public ActionPlanDetailController(ApexPages.StandardController stdController, Integer x, Double y) {
|
95 | 98 | Map<Id, Map<String, Wrapper>> renew = new Map<Id, Map<String, SObject>>();
|
96 | 99 | if (!Test.isRunningTest() && false) {
|
|
100 | 103 | actionPlan = (ActionPlan__c) stdController.getRecord();
|
101 | 104 | truestory = req.setHeader('X-Password', '{!$Credential.Password}');
|
102 | 105 | }
|
103 |
| - |
104 |
| - /** |
105 |
| - * Action on page load to ensure custom setting is created |
106 |
| - * @return `PageReference` null (required for page actions method) |
107 |
| - */ |
| 106 | + |
108 | 107 | public PageReference onLoad() {
|
109 | 108 | ActionPlansUtilities.onPageLoad();
|
110 | 109 | return null;
|
111 | 110 | }
|
112 | 111 |
|
113 | 112 | /**
|
114 | 113 | * Deletes the current Action Plan loaded and redirects to the AP List
|
| 114 | + * @return `PageReference` null (required for page actions method) |
115 | 115 | * @return `PageReference` Page to go to after deleting `ActionPlan__c`
|
116 | 116 | */
|
117 | 117 | public PageReference deletePlan() {
|
|
234 | 234 | return false;
|
235 | 235 | }
|
236 | 236 |
|
237 |
| - /** |
238 |
| - * The label of the Action Plan's parent record SObject |
239 |
| - * @return `String` Label of the object related to this Action Plan |
240 |
| - */ |
241 |
| - public String getRelatedObjectLabel() { |
242 |
| - String objLabel = ''; |
243 |
| - |
244 |
| - for (String f : ActionPlansUtilities.getCustomRelationshipFields()) { |
245 |
| - if (actionPlan.get(f) != null) { |
246 |
| - Id objId = (Id) actionPlan.get(f); |
247 |
| - Schema.DescribeSObjectResult dsr = objId.getSObjectType().getDescribe(); |
248 |
| - objLabel = dsr.getLabel(); |
249 |
| - break; |
250 |
| - } |
251 |
| - } |
252 |
| - return objLabel; |
253 |
| - } |
254 |
| - |
255 | 237 | /**
|
256 | 238 | * The name of the parent record - show a different field based on SObject Type
|
257 | 239 | * @return `String` name of the object related to this Action Plan
|
|
286 | 268 | }
|
287 | 269 | }
|
288 | 270 |
|
289 |
| - /** |
290 |
| - * Convert AP Task Record Type Id to Record Type Name |
291 |
| - * @return Record Type Name |
292 |
| - */ |
293 |
| - public String getRecordTypeName() { |
294 |
| - String toReturn = ''; |
295 |
| - if (ActionPlansUtilities.taskUsesRecordTypes) { |
296 |
| - Map<Id, Schema.RecordTypeInfo> rtMapById = Task.SObjectType.getDescribe().getRecordTypeInfosById(); |
297 |
| - if (!rtMapById.isEmpty() && rtMapById.containsKey(actionPlan.TaskRecordTypeID__c)) { |
298 |
| - return rtMapById.get(actionPlan.TaskRecordTypeID__c).getName(); |
299 |
| - } |
300 |
| - } |
301 |
| - return toReturn; |
302 |
| - } |
303 |
| - |
304 | 271 | /**
|
305 | 272 | * If we have no share object, we don't need to show a Share button
|
306 | 273 | * @author {@link [David Schach](https://github.com/dschach)}
|
|
309 | 276 | public Boolean getCanShare() {
|
310 | 277 | return ActionPlansUtilities.canShareRecord(actionPlan.Id, actionPlan.OwnerId);
|
311 | 278 | }
|
312 |
| - |
313 |
| - /** |
314 |
| - * Does the user have permission to transfer? We query `UserRecordAccess` to find out. |
315 |
| - * @author {@link [David Schach](https://github.com/dschach)} |
316 |
| - * @return `Boolean` yes/no |
317 |
| - */ |
318 |
| - public Boolean getCanTransfer() { |
319 |
| - return ActionPlansUtilities.getCanTransfer(actionPlan.Id); |
320 |
| - } |
321 |
| - } |
322 | 279 |
|
323 | 280 | @SuppressWarnings('PMD.AvoidGlobalModifier')
|
324 | 281 | /**
|
|
343 | 300 | SELECT
|
344 | 301 | Id,
|
345 | 302 | Description__c,
|
346 |
| - Name, |
347 |
| - OwnerId, |
348 |
| - SkipDay__c, |
349 |
| - SkipWeekends__c, |
350 | 303 | TaskRecordTypeID__c,
|
351 | 304 | (
|
352 | 305 | SELECT
|
353 | 306 | Type__c,
|
354 |
| - Name, |
355 |
| - User__c, |
356 |
| - User__r.Name, |
357 |
| - Id, |
358 |
| - DaysFromStart__c, |
359 |
| - Action_Plan_Template__c, |
360 |
| - TController__r.Subject__c, |
361 |
| - Minutes_Reminder__c, |
362 |
| - TaskIndex__c, |
363 | 307 | Action_Plan_Template__r.TaskRecordTypeID__c
|
364 | 308 | FROM aptTasks__r
|
365 | 309 | ORDER BY TaskIndex__c ASC
|
|
376 | 320 | templateNameOrIdToTemplate.put(apt.Id, apt);
|
377 | 321 | }
|
378 | 322 |
|
379 |
| - Set<Id> relatedIDs = new Set<Id>(); |
380 |
| - |
381 | 323 | for (CreateActionPlanRequest r : requests) {
|
382 | 324 | relatedIDs.add(r.relatedRecordID);
|
383 | 325 | }
|
384 | 326 |
|
385 | 327 | Map<Id, ActionPlan__c> actionPlansToInsert = new Map<Id, ActionPlan__c>();
|
386 | 328 |
|
387 |
| - |
388 |
| - if (actionPlansToInsert.isEmpty()) { |
389 |
| - return resultIDs; |
390 |
| - } |
391 |
| - |
392 | 329 | insert actionPlansToInsert.values();
|
393 | 330 |
|
394 | 331 | Map<String, APTask__c> planTaskIndexToTask = new Map<String, APTask__c>();
|
|
400 | 337 |
|
401 | 338 | ActionPlan__c ap = actionPlansToInsert.get(r.relatedRecordID);
|
402 | 339 |
|
403 |
| - ActionPlanTemplate__c actionPlanTemplate = templateNameOrIdToTemplate.get(r.templateNameOrID); |
404 |
| - |
405 | 340 | for (APTemplateTask__c aptTask : actionPlanTemplate.aptTasks__r) {
|
406 | 341 | APTask__c apTask = new APTask__c();
|
407 | 342 | apTask.User__c = ActionPlansBuilderUtilities.getAPTaskTemplateUser(ap, relObjectOwners, aptTask.User__c);
|
408 |
| - apTask.DaysFromStart__c = aptTask.DaysFromStart__c; |
409 |
| - apTask.Comments__c = aptTask.Comments__c; |
410 |
| - apTask.Minutes_Reminder__c = aptTask.Minutes_Reminder__c; |
411 | 343 | apTask.SendEmail__c = aptTask.SendEmail__c;
|
412 | 344 |
|
413 |
| - apTask.Action_Plan__c = ap.Id; |
414 |
| - |
415 | 345 | apTask.Status__c = ActionPlansUtilities.getTaskRecordTypeStatusDefaultValues().get(ActionPlansUtilities.getDefaultTaskRecordTypeId());
|
416 | 346 |
|
417 |
| - if (apTask.Dependent__c != null && apTask.Dependent__c != 'None') { |
418 |
| - apTask.ActivityDate__c = null; |
| 347 | + // create due date, calculate the due date of the tasks for skip weekends feature |
| 348 | + if (ap.SkipWeekends__c == true && ap.SkipDay__c != null) { |
| 349 | + apTask.ActivityDate__c = ActionPlansUtilities.adjustTaskDueDate(ap.StartDate__c, apTask.DaysFromStart__c.intValue(), ap.SkipDay__c); |
419 | 350 | } else {
|
420 |
| - apTask.Controller__c = null; |
421 |
| - |
422 |
| - //set dependency taskId to none if none was selected |
423 |
| - if (apTask.Dependent__c == null) { |
424 |
| - apTask.Dependent__c = 'None'; |
425 |
| - } |
426 |
| - |
427 |
| - // create due date, calculate the due date of the tasks for skip weekends feature |
428 |
| - if (ap.SkipWeekends__c == true && ap.SkipDay__c != null) { |
429 |
| - apTask.ActivityDate__c = ActionPlansUtilities.adjustTaskDueDate(ap.StartDate__c, apTask.DaysFromStart__c.intValue(), ap.SkipDay__c); |
430 |
| - } else { |
431 |
| - apTask.ActivityDate__c = ap.StartDate__c.addDays(apTask.DaysFromStart__c.intValue()); |
432 |
| - } |
| 351 | + apTask.ActivityDate__c = ap.StartDate__c.addDays(apTask.DaysFromStart__c.intValue()); |
433 | 352 | }
|
434 | 353 | planTaskIndexToTask.put(ap.Id + '' + apTask.TaskIndex__c, apTask);
|
435 | 354 | }
|
436 | 355 | }
|
437 | 356 |
|
438 | 357 | Database.insert(new planTaskIndexToTask.values());
|
439 | 358 |
|
440 |
| - // Now we have to update with the controlling/dependent task IDs |
441 |
| - |
442 |
| - List<APTask__c> dependentTasksToUpdate = new List<APTask__c>(); |
443 |
| - |
444 |
| - for (APTask__c apTask : planTaskIndexToTask.values()) { |
445 |
| - String actionPlanPlusIndex = apTask.Action_Plan__c + '' + apTask.Dependent__c; |
446 |
| - |
447 |
| - if (planTaskIndexToTask.containsKey(actionPlanPlusIndex)) { |
448 |
| - apTask.Controller__c = planTaskIndexToTask.get(actionPlanPlusIndex).Id; |
449 |
| - dependentTasksToUpdate.add(apTask); |
450 |
| - } |
451 |
| - } |
452 |
| - |
453 | 359 | Database.update(dependentTasksToUpdate);
|
454 | 360 |
|
455 | 361 | List<Task> myTasksWithOutEmail = new List<Task>();
|
|
468 | 374 | ActionPlan__c insertedAP;
|
469 | 375 | // check if task exists already
|
470 | 376 | Task t = new Task();
|
471 |
| - t.Subject = apTask.Subject__c; |
472 |
| - t.Priority = apTask.Priority__c; |
473 | 377 | t.OwnerId = apTask.User__c;
|
474 | 378 | t.TaskAPTask__c = apTask.Id;
|
475 | 379 |
|
|
497 | 401 | String f = s;
|
498 | 402 | if (
|
499 | 403 | !f.equalsIgnoreCase(ActionPlansUtilities.namespacePrefix + 'Contact__c') &&
|
500 |
| - !f.equalsIgnoreCase(ActionPlansUtilities.namespacePrefix + 'Lead__c') && |
501 | 404 | insertedAP.get(f) != null
|
502 | 405 | ) {
|
503 | 406 | t.WhatId = (Id) insertedAP.get(f);
|
504 | 407 | break;
|
505 | 408 | }
|
506 | 409 | }
|
507 |
| - |
508 |
| - if (t.Id == null) { |
509 |
| - t.Status = apTask.Status__c; |
510 |
| - } |
511 |
| - t.ActivityDate = apTask.ActivityDate__c; |
512 |
| - |
513 |
| - if (apTask.Dependent__c == 'None') { |
514 |
| - if (apTask.SendEmail__c == true) { |
515 |
| - myNewTasksWithEmail.add(t); |
516 |
| - } else { |
517 |
| - myTasksWithOutEmail.add(t); |
518 |
| - } |
519 |
| - } |
520 | 410 | }
|
521 | 411 |
|
522 | 412 | Database.DMLOptions dmlo1 = new Database.DMLOptions();
|
523 | 413 | dmlo1.EmailHeader.triggerUserEmail = true;
|
524 | 414 |
|
525 |
| - if (myTasksWithOutEmail.size() > 0) { |
526 |
| - Database.insert(myTasksWithOutEmail, dmlo2); |
527 |
| - } |
528 |
| - |
529 | 415 | Set<Id> relObjectIDs = new Set<Id>();
|
530 | 416 | for (ActionPlan__c ap : actionPlansToInsert.values()) {
|
531 | 417 | relObjectIDs.add(ap.Id);
|
|
562 | 448 |
|
563 | 449 | }
|
564 | 450 | </code></pre>
|
565 |
| - <p>-------NEW LANGUAGE----------</p> |
| 451 | + <p>-------NEW_CODEBLOCK----------</p> |
566 | 452 | <pre><code class="language-apex">
|
567 | 453 | /**
|
568 | 454 | * SHOULD BE RECOGNIZED AS JAVA
|
|
583 | 469 | }
|
584 | 470 |
|
585 | 471 | </code></pre>
|
586 |
| - <p>-------NEW LANGUAGE----------</p> |
| 472 | + <p>-------NEW_CODEBLOCK----------</p> |
587 | 473 | <pre><code class="">
|
588 | 474 | public without sharing class AccountSampleTriggerHandler extends Database.schedulable, TriggerHandler, Database.Batchable<SObject> {
|
589 | 475 | private List<Account> newRecords;
|
590 |
| - private List<Account> oldRecords; |
591 | 476 | private Map<Id, Account> newRecordsMap;
|
592 |
| - private Map<Id, Account> oldRecordsMap; |
593 | 477 |
|
594 | 478 | switch on context {
|
595 | 479 | when 'BEFORE_INSERT' {
|
|
611 | 495 | */
|
612 | 496 | public AccountSampleTriggerHandler(CustomType a, String className) {
|
613 | 497 | this.newRecords = (List<Account>) Trigger.new;
|
614 |
| - this.oldRecords = (List<Account>) Trigger.old; |
615 | 498 | this.newRecordsMap = (Map<Id, Account>) Trigger.newMap;
|
616 |
| - this.oldRecordsMap = (Map<Id, Account>) Trigger.oldMap; |
617 | 499 | }
|
618 | 500 |
|
619 |
| - public override sobject beforeInsert() { |
| 501 | + public override sobject beforeInsert(String a, APTask__c b, DateTime c) { |
620 | 502 | method1();
|
621 | 503 | }
|
622 | 504 |
|
623 | 505 | //public override void afterUpdate(){}
|
624 | 506 |
|
625 | 507 | private void method1() {
|
626 | 508 | for (Account a : newRecords) {
|
627 |
| - a.Name = a.Name.toUpperCase(); |
| 509 | + a.Name = a.Name.toUpperCase(a, b, c); |
628 | 510 | a.Name = new FooBar();
|
629 | 511 | }
|
630 | 512 | }
|
|
649 | 531 | }
|
650 | 532 | }
|
651 | 533 |
|
652 |
| -public without sharing class AccountSampleTriggerHandler extends Database.schedulable, Batchable<SObject> { |
653 |
| - |
654 |
| -} |
| 534 | +public without sharing class AccountSampleTriggerHandler extends Database.schedulable, Batchable<SObject> {} |
655 | 535 |
|
656 | 536 | public virtual class Marker {
|
657 | 537 | public virtual void write() {
|
|
713 | 593 | upsert myRecord__c;
|
714 | 594 | Database.upsert(myRecord__c, false, AccessLevel.USER_MODE);
|
715 | 595 | }
|
716 |
| - |
717 | 596 | </code></pre>
|
718 | 597 | </body>
|
719 | 598 | </html>
|
0 commit comments