• ckellie
  • NEWBIE
  • 470 Points
  • Member since 2007

  • Chatter
    Feed
  • 16
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 212
    Questions
  • 262
    Replies
Why can't Process Builder flow criteria return false without the throwing an error. I have a process with a criteria of field "test" = true and then an action if the criteria returns true. If criteria returns false I receive the below error:

 System.DmlException: Insert failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, We can't save this record because the “Opportunity Process Builder” process failed. Give your Salesforce admin these details. <b>An unhandled fault has occurred in this flow</b><br>An unhandled fault has occurred while processing the flow. Please contact your system administrator for more information.: []

An apex class is referenced as causing the error.

Belowq are my questions:
1. What unhandled fault is the message referring to?
2. Is the fact the process builder criteria returning false, an error in and of itself?
3. How do I handle the unhandled fault and where?

I am not sure how or what to post as the error is between a test class and a process builder flow.

Thank you

 
I have installed eclipse and cannot load the default workspace. I receive a message that says an error has occurred. and below is the log file:

!SESSION 2018-08-31 13:58:15.145 -----------------------------------------------
eclipse.buildId=4.6.3.M20170301-0400
java.version=10.0.2
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Framework arguments:  -product org.eclipse.epp.package.reporting.product
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.reporting.product

!ENTRY org.eclipse.osgi 4 0 2018-08-31 13:58:21.852
!MESSAGE Application error
!STACK 1
org.eclipse.e4.core.di.InjectionException: java.lang.NoClassDefFoundError: javax/annotation/PostConstruct
    at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:386)
    at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:294)
    at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:162)
    at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createDefaultHeadlessContext(E4Application.java:490)
    at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createDefaultContext(E4Application.java:504)
    at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createE4Workbench(E4Application.java:203)
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:632)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:610)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:138)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.base/java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:673)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:610)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1519)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1492)
Caused by: java.lang.NoClassDefFoundError: javax/annotation/PostConstruct
    at org.eclipse.e4.core.internal.di.InjectorImpl.inject(InjectorImpl.java:151)
    at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:375)
    ... 23 more
Caused by: java.lang.ClassNotFoundException: javax.annotation.PostConstruct cannot be found by org.eclipse.e4.core.di_1.6.1.v20160712-0927
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:410)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:372)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:364)
    at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:161)
    at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
    ... 25 more

!ENTRY org.eclipse.e4.ui.workbench 4 0 2018-08-31 13:58:21.877
!MESSAGE FrameworkEvent ERROR
!STACK 0
java.lang.NoClassDefFoundError: javax/annotation/PreDestroy
    at org.eclipse.e4.core.internal.di.InjectorImpl.disposed(InjectorImpl.java:426)
    at org.eclipse.e4.core.internal.di.Requestor.disposed(Requestor.java:154)
    at org.eclipse.e4.core.internal.contexts.ContextObjectSupplier$ContextInjectionListener.update(ContextObjectSupplier.java:78)
    at org.eclipse.e4.core.internal.contexts.TrackableComputationExt.update(TrackableComputationExt.java:111)
    at org.eclipse.e4.core.internal.contexts.TrackableComputationExt.handleInvalid(TrackableComputationExt.java:74)
    at org.eclipse.e4.core.internal.contexts.EclipseContext.dispose(EclipseContext.java:176)
    at org.eclipse.e4.core.internal.contexts.osgi.EclipseContextOSGi.dispose(EclipseContextOSGi.java:106)
    at org.eclipse.e4.core.internal.contexts.osgi.EclipseContextOSGi.bundleChanged(EclipseContextOSGi.java:139)
    at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:903)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
    at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
    at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:213)
    at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:120)
    at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:112)
    at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:156)
    at org.eclipse.osgi.container.Module.publishEvent(Module.java:476)
    at org.eclipse.osgi.container.Module.doStop(Module.java:634)
    at org.eclipse.osgi.container.Module.stop(Module.java:498)
    at org.eclipse.osgi.container.SystemModule.stop(SystemModule.java:202)
    at org.eclipse.osgi.internal.framework.EquinoxBundle$SystemBundle$EquinoxSystemModule$1.run(EquinoxBundle.java:165)
    at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: javax.annotation.PreDestroy cannot be found by org.eclipse.e4.core.di_1.6.1.v20160712-0927
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:410)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:372)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:364)
    at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:161)
    at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
    ... 21 more
!SESSION 2018-08-31 14:00:45.581 -----------------------------------------------
eclipse.buildId=4.6.3.M20170301-0400
java.version=10.0.2
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Framework arguments:  -product org.eclipse.epp.package.reporting.product
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.reporting.product

!ENTRY org.eclipse.osgi 4 0 2018-08-31 14:01:47.876
!MESSAGE Application error
!STACK 1
org.eclipse.e4.core.di.InjectionException: java.lang.NoClassDefFoundError: javax/annotation/PostConstruct
    at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:386)
    at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:294)
    at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:162)
    at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createDefaultHeadlessContext(E4Application.java:490)
    at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createDefaultContext(E4Application.java:504)
    at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createE4Workbench(E4Application.java:203)
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:632)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:610)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:138)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.base/java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:673)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:610)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1519)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1492)
Caused by: java.lang.NoClassDefFoundError: javax/annotation/PostConstruct
    at org.eclipse.e4.core.internal.di.InjectorImpl.inject(InjectorImpl.java:151)
    at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:375)
    ... 23 more
Caused by: java.lang.ClassNotFoundException: javax.annotation.PostConstruct cannot be found by org.eclipse.e4.core.di_1.6.1.v20160712-0927
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:410)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:372)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:364)
    at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:161)
    at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
    ... 25 more

!ENTRY org.eclipse.e4.ui.workbench 4 0 2018-08-31 14:01:47.883
!MESSAGE FrameworkEvent ERROR
!STACK 0
java.lang.NoClassDefFoundError: javax/annotation/PreDestroy
    at org.eclipse.e4.core.internal.di.InjectorImpl.disposed(InjectorImpl.java:426)
    at org.eclipse.e4.core.internal.di.Requestor.disposed(Requestor.java:154)
    at org.eclipse.e4.core.internal.contexts.ContextObjectSupplier$ContextInjectionListener.update(ContextObjectSupplier.java:78)
    at org.eclipse.e4.core.internal.contexts.TrackableComputationExt.update(TrackableComputationExt.java:111)
    at org.eclipse.e4.core.internal.contexts.TrackableComputationExt.handleInvalid(TrackableComputationExt.java:74)
    at org.eclipse.e4.core.internal.contexts.EclipseContext.dispose(EclipseContext.java:176)
    at org.eclipse.e4.core.internal.contexts.osgi.EclipseContextOSGi.dispose(EclipseContextOSGi.java:106)
    at org.eclipse.e4.core.internal.contexts.osgi.EclipseContextOSGi.bundleChanged(EclipseContextOSGi.java:139)
    at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:903)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
    at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
    at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:213)
    at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:120)
    at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:112)
    at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:156)
    at org.eclipse.osgi.container.Module.publishEvent(Module.java:476)
    at org.eclipse.osgi.container.Module.doStop(Module.java:634)
    at org.eclipse.osgi.container.Module.stop(Module.java:498)
    at org.eclipse.osgi.container.SystemModule.stop(SystemModule.java:202)
    at org.eclipse.osgi.internal.framework.EquinoxBundle$SystemBundle$EquinoxSystemModule$1.run(EquinoxBundle.java:165)
    at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: javax.annotation.PreDestroy cannot be found by org.eclipse.e4.core.di_1.6.1.v20160712-0927
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:410)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:372)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:364)
    at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:161)
    at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
    ... 21 more
!SESSION 2018-08-31 14:02:45.454 -----------------------------------------------
eclipse.buildId=4.6.3.M20170301-0400
java.version=10.0.2
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Command-line arguments:  -os win32 -ws win32 -arch x86_64

!ENTRY org.eclipse.osgi 4 0 2018-08-31 14:02:54.424
!MESSAGE Application error
!STACK 1
org.eclipse.e4.core.di.InjectionException: java.lang.NoClassDefFoundError: javax/annotation/PostConstruct
    at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:386)
    at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:294)
    at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:162)
    at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createDefaultHeadlessContext(E4Application.java:490)
    at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createDefaultContext(E4Application.java:504)
    at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createE4Workbench(E4Application.java:203)
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:632)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:610)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:138)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.base/java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:673)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:610)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1519)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1492)
Caused by: java.lang.NoClassDefFoundError: javax/annotation/PostConstruct
    at org.eclipse.e4.core.internal.di.InjectorImpl.inject(InjectorImpl.java:151)
    at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:375)
    ... 23 more
Caused by: java.lang.ClassNotFoundException: javax.annotation.PostConstruct cannot be found by org.eclipse.e4.core.di_1.6.1.v20160712-0927
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:410)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:372)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:364)
    at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:161)
    at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
    ... 25 more

!ENTRY org.eclipse.e4.ui.workbench 4 0 2018-08-31 14:02:54.446
!MESSAGE FrameworkEvent ERROR
!STACK 0
java.lang.NoClassDefFoundError: javax/annotation/PreDestroy
    at org.eclipse.e4.core.internal.di.InjectorImpl.disposed(InjectorImpl.java:426)
    at org.eclipse.e4.core.internal.di.Requestor.disposed(Requestor.java:154)
    at org.eclipse.e4.core.internal.contexts.ContextObjectSupplier$ContextInjectionListener.update(ContextObjectSupplier.java:78)
    at org.eclipse.e4.core.internal.contexts.TrackableComputationExt.update(TrackableComputationExt.java:111)
    at org.eclipse.e4.core.internal.contexts.TrackableComputationExt.handleInvalid(TrackableComputationExt.java:74)
    at org.eclipse.e4.core.internal.contexts.EclipseContext.dispose(EclipseContext.java:176)
    at org.eclipse.e4.core.internal.contexts.osgi.EclipseContextOSGi.dispose(EclipseContextOSGi.java:106)
    at org.eclipse.e4.core.internal.contexts.osgi.EclipseContextOSGi.bundleChanged(EclipseContextOSGi.java:139)
    at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:903)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
    at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
    at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:213)
    at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:120)
    at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:112)
    at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:156)
    at org.eclipse.osgi.container.Module.publishEvent(Module.java:476)
    at org.eclipse.osgi.container.Module.doStop(Module.java:634)
    at org.eclipse.osgi.container.Module.stop(Module.java:498)
    at org.eclipse.osgi.container.SystemModule.stop(SystemModule.java:202)
    at org.eclipse.osgi.internal.framework.EquinoxBundle$SystemBundle$EquinoxSystemModule$1.run(EquinoxBundle.java:165)
    at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: javax.annotation.PreDestroy cannot be found by org.eclipse.e4.core.di_1.6.1.v20160712-0927
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:410)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:372)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:364)
    at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:161)
    at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
    ... 21 more
!SESSION 2018-08-31 14:13:20.344 -----------------------------------------------
eclipse.buildId=4.6.3.M20170301-0400
java.version=10.0.2
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Command-line arguments:  -os win32 -ws win32 -arch x86_64

!ENTRY org.eclipse.osgi 4 0 2018-08-31 14:13:28.900
!MESSAGE Application error
!STACK 1
org.eclipse.e4.core.di.InjectionException: java.lang.NoClassDefFoundError: javax/annotation/PostConstruct
    at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:386)
    at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:294)
    at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:162)
    at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createDefaultHeadlessContext(E4Application.java:490)
    at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createDefaultContext(E4Application.java:504)
    at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createE4Workbench(E4Application.java:203)
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:632)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:610)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:138)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.base/java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:673)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:610)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1519)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1492)
Caused by: java.lang.NoClassDefFoundError: javax/annotation/PostConstruct
    at org.eclipse.e4.core.internal.di.InjectorImpl.inject(InjectorImpl.java:151)
    at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:375)
    ... 23 more
Caused by: java.lang.ClassNotFoundException: javax.annotation.PostConstruct cannot be found by org.eclipse.e4.core.di_1.6.1.v20160712-0927
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:410)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:372)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:364)
    at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:161)
    at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
    ... 25 more

Why cant eclipse load the default workspace?
A product sort button has been working on my org for the last 4 years without problems until now. The button is resorting the products in the standard product sort page, but it is returning the product sort page without saving the new product order.  How can append the button and code to resort the products and save the products in the new sort order? Below is the javascript button and supporting class.
 
Button:

{!REQUIRESCRIPT("/soap/ajax/36.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/36.0/apex.js")}
{!REQUIRESCRIPT("https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js")}

var oppID = '{!Quote.Id}';

//call the apex web service to get the OLIs in the desired sort order for this opp
var result = sforce.apex.execute("customQuoteSort","MRsort",{oppID: oppID});   

//need to post a form to /oppitm/lineitemsort.jsp because this is how SFDC
//does it but there is not direct API to do the sorting (thus the awkward workaround)
var form = document.createElement("form");
form.setAttribute("method", "post");
form.setAttribute("action", "/oppitm/lineitemsort.jsp?id="+oppID+"&retURL=%2F"+oppID);

//set the id of the request to the opportunity ID
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", 'hidden');
hiddenField.setAttribute("name", 'id');
hiddenField.setAttribute("value", '{!Quote.Id}');   
form.appendChild(hiddenField);

//the name of the sorted OLI list that the JSP is expecting is "duel0"
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", 'hidden');
hiddenField.setAttribute("name", 'duel0');
hiddenField.setAttribute("value", String(result));
form.appendChild(hiddenField);

var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", 'hidden');
hiddenField.setAttribute("name", 'retURL');
hiddenField.setAttribute("value", '/oppid');
form.appendChild(hiddenField);

//set to save
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", 'hidden');
hiddenField.setAttribute("name", 'save');
hiddenField.setAttribute("value", ' Save ');
form.appendChild(hiddenField);

//need to do this so it works in IE
document.body.appendChild(form);

//submit!!
form.submit();
 
Supporting Class:

global class customQuoteSort {
    webservice static String MRsort(Id QID)
    {        
    //pull back the qlis in a specific sort order        
    List<QuoteLineItem> qlis = [Select qli.Id, qli.Quote_Item_Number__c       
           From QuoteLineItem qli        
                   Where qli.QuoteId = :QId
                   ORDER BY qli.Quote_Item_Number__c];
                //build the comma separated 15 character qli Id string to send back
        String sortedIds = '';
                            for(QuoteLineItem qli : qlis)
        {
            sortedIds += String.valueOf(qli.Id).substring(0,15) + ',';
              }
                //remove the last comma
            sortedIds = sortedIds.substring(0,sortedIds.length() - 1);
        return sortedIds;
    }
}

The above automation was based on this link: https://developer.salesforce.com/forums/?id=906F000000094fvIAA

While I have not seen anything doing away with Javascript buttons in classic. Ideally it would be great to get this button back up and running and then work on a longer-term solution if I need to.

Any help will be appreciated.
 
Is there a way to allow the end user to login directly to Salesforce while basing my network as the identity provider? Would someone supply a link with a simplistic example?
I have created single sign-on from my company to Salesforce. I now need to use the login credentials from the SSO to a connected app. I have studied the implementation guide and have learned that I need to transport the user credentials to an auth provider. What are the steps to do this?
I have a business process managed with workflow rules that I an debating using apex code for but don't know which way to proceed. Currently I have aproximately 80 workflow rules and 100 field updates active on one object too write a description of the record when the record is created and updated. These field updates are updating a string of text fields. In another automation the text fields are concatenated updated into a long text field to form a bulletted list.

I now need to combine both processes into one, where the logic from the workflow rules and field updates will run and update the long text field. Although I have been programming for years, this is the largest project that I have tackled. Would anyone advise me on how to structure this project to run the most efficiently and allow for the best maintanence?

Thank you

The below visualforce page renders in excel appropriately, but I would like to take the functionality further.


 

<apex:page controller="QuoteProductCostSalesSheetExcel" tabStyle="Opportunity" contenttype="application/vnd.ms-excel#Cost-Sales-Sheet.xls" cache="true" standardstylesheets="false" >
 <apex:form > 
 
 <apex:pageBlock title="SE Margin Spreadsheet for {!opname}"  >
<h3>All currency is in {!currencyisocode}.</H3>
<apex:dataTable title="SE Margin Spreadsheet for {!opname}" border="1" value="{!TheExcelWrapper}" var="Wrapper" cellpadding="5" id="theTable3" rowClasses="odd,even" styleClass="tableClass">

           <apex:column >
                <apex:facet name="header">Sort Order</apex:facet>
                <apex:outputText value="{!Wrapper.column1}"/>
          </apex:column>
          
          <apex:column >
                <apex:facet name="header">Product Name</apex:facet>
                <apex:outputText value="{!Wrapper.column2}"/>
          </apex:column>
    
          <apex:column style="text-align:right;" >
                <apex:facet name="header">Unit Price</apex:facet>
                <apex:outputtext value="{!if(Wrapper.column3==null,'',Currsign)}{!
                                                    If(len(text(Wrapper.column3))==6, left(text(Wrapper.column3),3)&','&right(text(Wrapper.column3),3),
                                                        If(len(text(Wrapper.column3))==5, left(text(Wrapper.column3),2)&','&right(text(Wrapper.column3),3),
                                                            If(len(text(Wrapper.column3))==4, left(text(Wrapper.column3),1)&','&right(text(Wrapper.column3),3),Wrapper.column3)))}"/>

          </apex:column>

          <apex:column style="text-align:right;" >
                <apex:facet name="header">Quantity</apex:facet>
                <apex:outputText value="{!If(right(text(Wrapper.column4),3)=='.00',left(text(Wrapper.column4), Len(text(Wrapper.column4))-3),text(Wrapper.column4))}"/>

          </apex:column>

          <apex:column style="text-align:right;" >
                <apex:facet name="header">Cost Each</apex:facet>
                
                <apex:outputText value="{!if(Wrapper.column5==null,'',Currsign)}{!If(len(text(Wrapper.column5))==6, left(text(Wrapper.column5),3)&','&right(text(Wrapper.column5),3),
                                                        If(len(text(Wrapper.column5))==5, left(text(Wrapper.column5),2)&','&right(text(Wrapper.column5),3),
                                                            If(len(text(Wrapper.column5))==4, left(text(Wrapper.column5),1)&','&right(text(Wrapper.column5),3),Wrapper.column5)))}"/>

          </apex:column>

          <apex:column style="text-align:right;" >
                <apex:facet name="header">Before Discount FM (%)</apex:facet>
                <apex:outputText value="=[Quantity]"/>
                <!--      <apex:outputText value="{!Wrapper.column6}"/>-->

          </apex:column>

          <apex:column style="text-align:right;" >
                <apex:facet name="header">Subtotal</apex:facet>
                <apex:outputText value="{!Wrapper.column7}"/>

          </apex:column>
                    
          <apex:column style="text-align:right;" >
                <apex:facet name="header">Discount(%)</apex:facet>
                <apex:outputText value="{!Wrapper.column8}"/>

          </apex:column>  

          <apex:column style="text-align:right;" >
                <apex:facet name="header">After Discount Amount</apex:facet>
                                <apex:outputtext value="{!Wrapper.column9}"/>
          </apex:column>  

          <apex:column style="text-align:right;" >
                <apex:facet name="header">After Discount FM (%)</apex:facet>
                <apex:outputText value="{!Wrapper.column10}"/>
          </apex:column>  

                         
          <apex:column style="text-align:right;" >
                <apex:facet name="header">Total Price</apex:facet>
                <apex:outputtext value="{!Wrapper.column11}"/>
          </apex:column>

          <apex:column style="text-align:right;" >
                <apex:facet name="header">Discount Error Notification</apex:facet>

          </apex:column>

    </apex:dataTable>
<apex:dataTable title="SE Margin Spreadsheet for {!opname}" border="1" value="{!TheTotalWrapper}" var="tWrapper" cellpadding="5" id="theTable2" rowClasses="odd,even" styleClass="tableClass">



           <apex:column >

                <apex:outputText value="{!tWrapper.column1}"/>

          </apex:column>
          
          <apex:column >

                <apex:outputText value="{!tWrapper.column2}"/>

          </apex:column>
          

          <apex:column style="text-align:right;" >

                <apex:outputtext value="{!If(len(tWrapper.column3)==6, left(tWrapper.column3,3)&','&right(tWrapper.column3,3),
                                                        If(len(tWrapper.column3)==5, left(tWrapper.column3,2)&','&right(tWrapper.column3,3),
                                                            If(len(tWrapper.column3)==4, left(tWrapper.column3,1)&','&right(tWrapper.column3,3),tWrapper.column3)))}"/>

          </apex:column>


           <apex:column style="text-align:right;"  >

                <apex:outputText value="{!tWrapper.column4}"/>

          </apex:column>


           <apex:column style="text-align:right;"  >

                <apex:outputText value="{!tWrapper.column5}"/>

          </apex:column>


           <apex:column style="text-align:right;"  >

            <apex:outputText value="{!tWrapper.column6}"/>

          </apex:column>          


           <apex:column style="text-align:right;"  >
            
            <apex:outputText value="{!tWrapper.column7}"/>

          </apex:column>          

  <!--After discount amount            -->

           <apex:column style="text-align:right;"  >

            <apex:outputText value="{!tWrapper.column8}"/>


          </apex:column>

           <apex:column style="text-align:right;" >

                <apex:outputText value="{!tWrapper.column9}"/>

          </apex:column>


           <apex:column style="text-align:right;" >

                <apex:outputText value="{!tWrapper.column10}"/>

          </apex:column>

           <apex:column style="text-align:right;" >

                <apex:outputText value="{!tWrapper.column11}"/>

          </apex:column>

           <apex:column style="text-align:right;" >

                <apex:outputText value="{!tWrapper.column12}"/>

          </apex:column>

      </apex:datatable>
      <apex:facet name="Footer">All numbers are displayed in {!Currsign}</apex:facet>
    </apex:pageblock>
    </apex:form>
</apex:page>
In excel, if I highlight the rendered datatable, I can click insert table in the excel menu to convert the cells to a table. Is there any way I can programmically make the datatable an excel table?
  • September 20, 2016
  • Like
  • 0
How do I add three buttons on a javascript alert driven by a custom button? In my use case, I want to notify the user that not all data is entered on the opportunity page, but give the user the option to continue create a quote without the data, or return to the opportunity to add the information.

Below is the custom button:
REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
{!REQUIRESCRIPT('/soap/ajax/29.0/apex.js')}
var result = sforce.connection.query("SELECT id, opportunityid, role from OpportunityContactRole where opportunityid = '{!Opportunity.Id}' and role='Technical Contact'");
var records = result.getArray("records");

var error1string = "Error:\n";
var error1found = false;
if(!records[0]==null) {
error1string += "The technical contact is not listed on the Opportunity nor will be listed on the budget proposal. Please add the technical contact to contact roles.";
error1found = true;
}


if(records[0]==null) {
alert("The technical contact is not listed on the Opportunity nor will be listed on the budget proposal. Do you want to continue to create the quote or do you want to add the technical contact?");
window.location = "{!URLFOR($Action.Opportunity.View,Opportunity.Id)}";
} else {
/apex/QuoteNotification?oppid={!Opportunity.Id}&Type="B"&Rec="Budget Quote"
}

How do I add two buttons to the alert?
I have created the following dynamic picklist.
for(firepond__Configurable__c prod : [select id, name, firepond__Item_Id__r.name, firepond__Item_Id__c, firepond__Item_Id__r.Salesforce_Product__r.name, firepond__Item_Id__r.Salesforce_Product__r.id, firepond__Item_Id__r.firepond__Description__c, 
                                                                firepond__RecordType__c from firepond__Configurable__c where firepond__RecordType__c = 'Product'
                                                                and firepond__Item_Id__c<>'' and (Not firepond__Item_Id__r.name like '%Veryx%')]) {
                    
                    productNamesMap.put(prod.Id, prod.firepond__Item_Id__r.firepond__Description__c);
                    productIdsMap.put(prod.firepond__Item_Id__r.firepond__Description__c, prod.Id);
                    FPXProd.add(prod.firepond__Item_Id__r.Salesforce_Product__r.name);
                        }             
                    if(productNamesMap != null){
                    productNamesList = productNamesMap.values();
                    }

        for(Product2 prod : [ select id, name from product2 where not(name =:FPXprod)]){
                    productNamesList.add(prod.name);
                    produc
The end user can filter this picklist by typing keywords in the text field. If the end user selects a value without filtering the picklist, the system will not return the currect selected value. But if the user filters the picklist to a few values, they will recieve the selected value. Why does the size of the picklist affects whether the system will return the value the user selects?

Thanks,
ckellie
 
The below code is perplexing me. The concept is to look up the default account's language and return it to the Opportunity. The opportunity's language is note being updated. Below is the code:
public class DefaultOpportunityLanguage{
  // These variables store Trigger.oldMap and Trigger.newMap
   Map<Id, Opportunity> oldOpps;
   Map<Id, Opportunity> newOpps;
   Map<Id, Account> accmap = new Map<Id, Account>();
   Set<id> aid = new Set<id>();
   Set<id> oid = new Set<id>();
   String scountry;
   
  // This is the constructor
  // A map of the old and new records is expected as inputs
  public DefaultOpportunityLanguage(
    Map<Id, Opportunity> oldTriggerOpps, 
    Map<Id, Opportunity> newTriggerOpps) {
      oldOpps = oldTriggerOpps;
      newOpps = newTriggerOpps;
  }

  // The one method your master trigger will call
  public void DefaultOpportunityLanguage() {
    string u = 'Angola';
    Map<string, pw_cc__CountryObject__c> countrymap = new Map<string, pw_cc__CountryObject__c>();
    
    for(pw_cc__CountryObject__c p : [select name,Primary_Language__c from pw_cc__CountryObject__c]){
      countrymap.put(p.name, p);
    }
    system.debug('*************5countrymap size:' +countrymap.size());    
    
    for (Opportunity newOpp : oldOpps.values()) {
            system.debug('*************1accountid:' +newOpp.accountid);
            aid.add(newOpp.accountid);
            oid.add(newOpp.id);
            
  } 
      for(account a : [select id, shippingcountry from account where id in:aid]){
          accMap.put(a.id,a);
      }

    for (Opportunity newOpp : [select id, accountid, Language_to_prepare_docs_in__c from Opportunity where id =: oid]) {
        system.debug('*************3id:' +newOpp.id);

           scountry = accMap.get(newOpp.accountid).shippingCountry;
            system.debug('*************4scountry:' +scountry);
            if(countrymap.get(scountry).Primary_Language__c<>''){
               newOpp.Language_to_prepare_docs_in__c = countrymap.get(scountry).Primary_Language__c;

           scountry = '';
         }
  } 
  
 }
}
The variable scountry is populated, the countrymap is populated, and I have confirmed that the database is complete with the appropriate records. But the language is not being written back tothe opportunity.
 
The below code is evaluating multiple fields on the same record and then creating the multiple records

For example:
The fields, Plain_Text_Desc_Line_01__c and HTML_Description_Line_01__c, will create the first product description record.
The fields, Plain_Text_Desc_Line_02__c and HTML_Description_Line_02__c, will create the second product description record
The fields, Plain_Text_Desc_Line_03__c and HTML_Description_Line_03__c, will create the third product description record
The fields, Plain_Text_Desc_Line_04__c and HTML_Description_Line_04__c, will create the fourth product description record
The fields, Plain_Text_Desc_Line_05__c and HTML_Description_Line_05__c, will create the fifth product description record
 
/*This for loop will create multiple Product Description records from one App Matrix record. Each Product Description Record comprises of a Plain_Text_Desc field and a HTML_Description field.
      The new record is attached to the appropriate template record and is given a sequence number.
    */
    for(App_Matrix__c apm : alist){
         String extid = oid+'-'+apm.name;
         linesort = 1;
      If(apm.Plain_Text_Desc_Line_01__c<>null){ //If Plain_Text_Desc_Line_01 is not null a new product description record is created and attached to the parent template record.
     
         Product_Description__c pd = new Product_Description__c();
             pd.Template_ID__c = templates.get(extid).id;
             pd.sequence__c = linesort;
             pd.Product_Description_English__c = apm.Plain_Text_Desc_Line_01__c;
             pd.Product_Description_HTML__c = apm.HTML_Description_Line_01__c;
             
             pdlist.add(pd);
             linesort=linesort+1;
             
        }
        
      If(apm.Plain_Text_Desc_Line_02__c<>null){ //If Plain_Text_Desc_Line_02 is not null a new product description record is created and attached to the parent template record.
     
         Product_Description__c pd = new Product_Description__c();
             pd.Template_ID__c = templates.get(extid).id;
             pd.sequence__c = linesort;
             pd.Product_Description_English__c = apm.Plain_Text_Desc_Line_02__c;
             pd.Product_Description_HTML__c = apm.HTML_Description_Line_02__c;
             
             pdlist.add(pd);
             linesort=linesort+1;
        }

      If(apm.Plain_Text_Desc_Line_03__c<>null){ //If Plain_Text_Desc_Line_03 is not null a new product description record is created and attached to the parent template record.
     
         Product_Description__c pd = new Product_Description__c();
             pd.Template_ID__c = templates.get(extid).id;
             pd.sequence__c = linesort;
             pd.Product_Description_English__c = apm.Plain_Text_Desc_Line_03__c;
             pd.Product_Description_HTML__c = apm.HTML_Description_Line_03__c;
             
             pdlist.add(pd);
             linesort=linesort+1;
        }
        
      If(apm.Plain_Text_Desc_Line_04__c<>null){ //If Plain_Text_Desc_Line_04 is not null a new product description record is created and attached to the parent template record.
     
         Product_Description__c pd = new Product_Description__c();
             pd.Template_ID__c = templates.get(extid).id;
             pd.sequence__c = linesort;
             pd.Product_Description_English__c = apm.Plain_Text_Desc_Line_04__c;
             pd.Product_Description_HTML__c = apm.HTML_Description_Line_04__c;
             
             pdlist.add(pd);
             linesort=linesort+1;
        }
                
      If(apm.Plain_Text_Desc_Line_05__c<>null){ //If Plain_Text_Desc_Line_05 is not null a new product description record is created and attached to the parent template record.
     
         Product_Description__c pd = new Product_Description__c();
             pd.Template_ID__c = templates.get(extid).id;
             pd.sequence__c = linesort;
             pd.Product_Description_English__c = apm.Plain_Text_Desc_Line_05__c;
             pd.Product_Description_HTML__c = apm.HTML_Description_Line_05__c;
             
             pdlist.add(pd);
             linesort=linesort+1;
        }
     }  

        Insert pdlist;

How do I make this code more efficient?
I have a list of checkboxes in a wrapper class/pageblocktable that I want to limit the user to only choose one box.

Below is my script
function checkone(cb,conid)
{

   var inputElem = document.getElementsByTagName("input");
    for(var i=1; i<inputElem.length; i++)
    {
        if(inputElem[i].id.indexOf("checkedone")!=-1)
        {
            if(inputElem[i].name!=cb.name)
            {
                inputElem[i].checked=false;
            }
        }
    }
  
  
}

This automation is working great if I assign the checkbox to the records id and not the selected element:
<input type="checkbox" name="{!cp.con.id}" id="checkedone"  onclick="return checkone(this,'{!cp.con.id}')"  />

but when I use the selected element of the wrapper class the automation does not work.
<input type="checkbox" name="{!cp.selected}" id="checkedone"  onclick="return checkone(this,'{!cp.selected}')"  />

How do I change my function to control cp.selected, or change my wrapper class to process cp.con.id when the checkbox is selected? Below is my visualforce page and apex class

VFpage:
<apex:page standardcontroller="App_Matrix__c" extensions="ApplicationDefiner" tabStyle="App_Matrix__c" sidebar="false" showChat="false">
<script>
function checkone(cb,conid)
{

   var inputElem = document.getElementsByTagName("input");
    for(var i=1; i<inputElem.length; i++)
    {
        if(inputElem[i].id.indexOf("checkedone")!=-1)
        {
            if(inputElem[i].name!=cb.name)
            {
                inputElem[i].checked=false;
            }
        }
    }
  
  
}
</script>  

    <apex:sectionHeader title="Application Solution"/>
<apex:form >

    <apex:pageBlock title="Select Primary Application" mode="view"> 
           <apex:pageBlockButtons >
                <apex:commandButton value="Process Selected" action="{!processSelected}" rerender="resultTemtbl" />
            </apex:pageBlockButtons>
       <apex:pageblockTable value="{!CProduct}" title="Select Primary Application" var="cp" id="pbselecttbl">

       <apex:column headerValue="Primary Application" width="50px">

       <input type="checkbox" name="{!cp.selected}" id="checkedone"  onclick="return checkone(this,'{!cp.selected}')"  />
       <!--    <input type="checkbox" name="{!cp.con.id}" id="checkedone"  onclick="return checkone(this,'{!cp.con.id}')"  />  -->
        </apex:column>
           <apex:column value="{!cp.con.name}" headerValue="Name" width="60px"/>
           <apex:column value="{!cp.con.Condition_1__c}" headerValue="Primary Condition" width="60px"/>
           <apex:column value="{!cp.con.Condition_2__c}" headerValue="Additional Condition" width="60px"/>
           <apex:column value="{!cp.con.Shape_1__c}" headerValue="Primary Shape" width="60px"/>
           <apex:column value="{!cp.con.Shape_2__c}" headerValue="Additional Shape" width="60px"/>
           <apex:column value="{!cp.con.Defect_Description__c}" headerValue="Sort Criteria"/>
       
       </apex:pageblockTable><br/><br/>
    </apex:pageBlock><br/><br/> 
    <apex:pageBlock title="Template ID" mode="view" >  
       <apex:pageblockTable value="{!Configuration}" Title="Template ID" var="cp" id="resultTemtbl">

           <apex:column value="{!cp.name}" headerValue="Template ID" width="30px"/>
           <apex:column value="{!cp.Base_Model__c}" headerValue="Base Model" width="30px"/>
           <apex:column value="{!cp.Customer_Product__r.name}" headerValue="Name" width="40px"/>
           <apex:column value="{!cp.Condition_1__c}" headerValue="Primary Condition" width="60px"/>
           <apex:column value="{!cp.Condition_2__c}" headerValue="Additional Condition" width="60px"/>
           <apex:column value="{!cp.Shape_1__c}" headerValue="Primary Shape" width="60px"/>
           <apex:column value="{!cp.Shape_2__c}" headerValue="Additional Shape" width="60px"/>
           <apex:column value="{!cp.Defect_Description__c}" headerValue="Sort Criteria"/>
       
       </apex:pageblockTable>

    </apex:pageBlock>

</apex:form>
</apex:page>
Apex Class:
public with sharing class ApplicationDefiner {

    public ApplicationDefiner(ApexPages.StandardController controller) {
  oid =[SELECT id from Opportunity WHERE id =:ApexPages.currentPage().getParameters().get('oppid')].id;

    }

    id oid;
    public List<cCustomer> cpList {get; set;}
    public List<App_Matrix__c> aplist {get; set;}
    Boolean cpprimary;
    List<Customer_Product_Line_Item__c> selectedCpli = new List<Customer_Product_Line_Item__c>();
    Public Map<string, App_Matrix__c> apmap = new Map<string, App_Matrix__c>();
    Set<String> cpset = new Set<String>();
    Set<String> cpprimaryset = new Set<String>();


    public List<cCustomer> getCProduct() {
            cplist = new List<cCustomer>();
            for(Customer_Product_Line_Item__c c: [select id, Combo__c, Name, Customer_Product__r.Name,Condition_1__c, 
                    Condition_2__c,Shape_1__c, Shape_2__c,Defect_Description__c, Opportunity__c from Customer_Product_Line_Item__c where Opportunity__c =: oid]) {

                cplist.add(new cCustomer(c)); 
       }
        return cplist;
    }    


    public PageReference processSelected() {

        for(cCustomer cCon: cplist) {
            if(cCon.selected == true) {
                selectedCpli.add(cCon.con);

            }
               System.debug('#####'+cCon.selected);
        }

        System.debug('These are the selected Contacts...');
        for(Customer_Product_Line_Item__c con: selectedCpli) {
            cpset.add(con.combo__c);
            system.debug(con);
        }
         system.debug(cpset);
        cplist=null;
        return null;
    }

    public List<App_Matrix__c> getConfiguration() {
            aplist = new List<App_Matrix__c>();
            for(App_Matrix__c ac: [select Name, Base_Model__c, Customer_Product__r.name, Condition_1__c, Condition_2__c,Shape_1__c, Shape_2__c,combo__c,Defect_Description__c from App_Matrix__c where combo__c in: cpset]) {

                aplist.add(ac);
                System.debug('%%%%%%%%%%id'+ac.id);

            }
        return aplist;
    }



    public class cCustomer {
        public Customer_Product_Line_Item__c con {get; set;}
        public Boolean selected {get; set;}

        public cCustomer (Customer_Product_Line_Item__c c) {
            con = c;
            selected = false;
        }
    }
    
}

Thank you for your help



 
  • September 01, 2015
  • Like
  • 0
How do I include a Visual Basic macro in a visualforce page that is being rendered as an excel page?

The visualforce page below is rendered as excel:
<apex:page controller="contactquery" contentType="application/vnd.ms-excel#SalesForceExport.xls" cache="true">
    <apex:pageBlock title="Export Results" >
        <apex:pageBlockTable value="{!cs}" var="contact">
            <apex:column value="{!contact.ID}"/>
            <apex:column value="{!contact.Name}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>
Here is my controller:
public class contactquery{
    public List<Contact> cs{get; set;}
    public contactquery()
    {
    cs = new List<Contact>();
       for (Contact c : [Select id, Name from Contact])
       {       
           cs.add(c);
       }
    }
}
Below is my visual basic code
Sub Auto_Open()
'
' Auto_Open
'
' Keyboard Shortcut: Ctrl+k
'
    Application.PrintCommunication = False
    With ActiveSheet.PageSetup
        .PrintTitleRows = ""
        .PrintTitleColumns = ""
    End With
    Application.PrintCommunication = True
    ActiveSheet.PageSetup.PrintArea = ""
    Application.PrintCommunication = False
    With ActiveSheet.PageSetup
        .LeftHeader = ""
        .CenterHeader = ""
        .RightHeader = ""
        .LeftFooter = ""
        .CenterFooter = ""
        .RightFooter = ""
        .LeftMargin = Application.InchesToPoints(0.7)
        .RightMargin = Application.InchesToPoints(0.7)
        .TopMargin = Application.InchesToPoints(0.75)
        .BottomMargin = Application.InchesToPoints(0.75)
        .HeaderMargin = Application.InchesToPoints(0.3)
        .FooterMargin = Application.InchesToPoints(0.3)
        .PrintHeadings = False
        .PrintGridlines = False
        .PrintComments = xlPrintNoComments
        .PrintQuality = 600
        .CenterHorizontally = False
        .CenterVertically = False
        .Orientation = xlLandscape
        .Draft = False
        .PaperSize = xlPaperLetter
        .FirstPageNumber = xlAutomatic
        .Order = xlDownThenOver
        .BlackAndWhite = False
        .Zoom = 100
        .PrintErrors = xlPrintErrorsDisplayed
        .OddAndEvenPagesHeaderFooter = False
        .DifferentFirstPageHeaderFooter = False
        .ScaleWithDocHeaderFooter = True
        .AlignMarginsHeaderFooter = True
        .EvenPage.LeftHeader.Text = ""
        .EvenPage.CenterHeader.Text = ""
        .EvenPage.RightHeader.Text = ""
        .EvenPage.LeftFooter.Text = ""
        .EvenPage.CenterFooter.Text = ""
        .EvenPage.RightFooter.Text = ""
        .FirstPage.LeftHeader.Text = ""
        .FirstPage.CenterHeader.Text = ""
        .FirstPage.RightHeader.Text = ""
        .FirstPage.LeftFooter.Text = ""
        .FirstPage.CenterFooter.Text = ""
        .FirstPage.RightFooter.Text = ""
    End With
    Application.PrintCommunication = True
    Application.PrintCommunication = False
    With ActiveSheet.PageSetup
        .PrintTitleRows = ""
        .PrintTitleColumns = ""
    End With
    Application.PrintCommunication = True
    ActiveSheet.PageSetup.PrintArea = ""
    Application.PrintCommunication = False
    With ActiveSheet.PageSetup
        .LeftHeader = ""
        .CenterHeader = ""
        .RightHeader = ""
        .LeftFooter = ""
        .CenterFooter = ""
        .RightFooter = ""
        .LeftMargin = Application.InchesToPoints(0.7)
        .RightMargin = Application.InchesToPoints(0.7)
        .TopMargin = Application.InchesToPoints(0.75)
        .BottomMargin = Application.InchesToPoints(0.75)
        .HeaderMargin = Application.InchesToPoints(0.3)
        .FooterMargin = Application.InchesToPoints(0.3)
        .PrintHeadings = False
        .PrintGridlines = False
        .PrintComments = xlPrintNoComments
        .PrintQuality = 600
        .CenterHorizontally = False
        .CenterVertically = False
        .Orientation = xlLandscape
        .Draft = False
        .PaperSize = xlPaperLetter
        .FirstPageNumber = xlAutomatic
        .Order = xlDownThenOver
        .BlackAndWhite = False
        .Zoom = False
        .FitToPagesWide = 1
        .FitToPagesTall = 0
        .PrintErrors = xlPrintErrorsDisplayed
        .OddAndEvenPagesHeaderFooter = False
        .DifferentFirstPageHeaderFooter = False
        .ScaleWithDocHeaderFooter = True
        .AlignMarginsHeaderFooter = True
        .EvenPage.LeftHeader.Text = ""
        .EvenPage.CenterHeader.Text = ""
        .EvenPage.RightHeader.Text = ""
        .EvenPage.LeftFooter.Text = ""
        .EvenPage.CenterFooter.Text = ""
        .EvenPage.RightFooter.Text = ""
        .FirstPage.LeftHeader.Text = ""
        .FirstPage.CenterHeader.Text = ""
        .FirstPage.RightHeader.Text = ""
        .FirstPage.LeftFooter.Text = ""
        .FirstPage.CenterFooter.Text = ""
        .FirstPage.RightFooter.Text = ""
    End With
    Application.PrintCommunication = True
End Sub
Thank you

 
The below visualforce page is rendered in excel. The problem is the datalist is sorted in descending order rather than ascending order. In this code the footer with the totals are listed at the top of the table, the first line of the table. When the table is rendered in Salesforce, the records is sorted in ascending order, the same page rendered in excel sorts the table in descending order with the footer listed at the first line below the header row.

Below is the apex code
global with sharing class ProductCostSalesSheet3 {

    public decimal unit_price { get; set; }
    public decimal totalprice { get; set; }
    public decimal cost { get; set; }
    public decimal totaldiscount { get; set; }
    public String opname { get; set; }
    public decimal items { get; set; }
    public String currsign { get; set; }
    Set<String> propop = new Set<String>();
    public string sequence { get; set; }
    id oppi;
    Public final Opportunity o;
    

    public ProductCostSalesSheet3() {
        o = [select id, currencyisocode, name from Opportunity where id =: System.currentpageReference().getParameters().get('oppid')];
        system.debug('*********************000000000:'+ o); 
        oppi = o.id;  
       opname = o.name;
       If(o.currencyisocode == 'USD'){
       currsign = '$';
       }
       
       If(o.currencyisocode == 'EUR'){
       currsign = '€';
       }
       
        system.debug('*********************000000001:'+ currsign); 
        
    }

    public PageReference ExporttoExcel() {
        
        pagereference excel = new pagereference('/apex/productcostsalessheettoexcel3?oppid='+o.id);
        
        return excel;
    }


    public  List<TheWrapper> getTheWrapper(){
      
     For(Proposal_Option__c p : [select id, Opportunity_Product__c from Proposal_Option__c where Opportunity__c =: oppi]){
         If(propop.contains(p.Opportunity_Product__c)){}else{         
             propop.add(p.Opportunity_Product__c);
         }
     }
      
     List<TheWrapper> AllValues = new List<TheWrapper>();
           cost = 0;
           unit_price = 0;
           totalprice = 0;
           totaldiscount = 0;
           

       for(OpportunityLineItem oli: [select id, Quote_Item_Number__c, Product2.name, unitprice, discount, totalprice, cost_each__c, quantity, includes_Options__c from OpportunityLineItem where OpportunityId =: oppi]){
           
           
           If(propop.contains(oli.id)){           
          
           } else{
           sequence = string.valueof(oli.Quote_Item_Number__c);

           cost = cost + oli.cost_each__c;
           unit_price = unit_price + oli.unitprice;
           totalprice = totalprice + oli.totalprice;
           If( oli.discount > 0){ totaldiscount= totaldiscount+(oli.unitprice * oli.quantity * (oli.discount/100));}
           
           AllValues.add(new TheWrapper(sequence,oli.product2.name,oli.unitprice,oli.quantity, oli.cost_each__c, oli.discount,oli.totalprice,oli.includes_Options__c,oli.includes_Options__c));
          }
        
       }
       
       for(Proposal_Option__c p : [select id, Opportunity_Product__c, Description__c,quote_item_number__c, sequence__c,sales_price__c,discount__c,cost_each__c,unit_price__c,quantity__c from Proposal_Option__c where Opportunity__c =: oppi]){
           string name;
          
           If(p.cost_each__c ==null){} else{
           cost = cost + p.cost_each__c;}
           unit_price = unit_price + p.unit_price__c;
           totalprice = totalprice + p.sales_price__c;
           If( p.discount__c > 0){ totaldiscount=totaldiscount + (p.unit_price__c * p.quantity__c * (p.discount__c/100));}
           
           If( p.description__c.contains('List')){
               name = p.description__c.remove(' List Price');
           } else{
               name = 'Option: '+p.description__c;
           }
           sequence = p.quote_item_number__c +'-'+p.sequence__c;
           boolean checkbox = false;
           AllValues.add(new TheWrapper(sequence,name,p.unit_price__c,p.quantity__c,p.cost_each__c,p.discount__c,p.sales_price__c,checkbox,checkbox));


       }
           
       allValues.sort();
       
       items = allValues.size();
                 
       return AllValues ;
      

    }
}
Below is the Visualforce Page
<apex:page controller="ProductCostSalesSheet3" tabStyle="Opportunity" >
 <apex:form >
 
 <apex:pageBlock title="SE Margin Spreadsheet for {!opname}" >
     <apex:pageBlockButtons >
         <apex:commandButton action="{!ExporttoExcel}" Value="Export to Excel"/>
     </apex:pageBlockButtons>
<apex:dataTable title="SE Margin Spreadsheet for {!opname}" border="1" value="{!TheWrapper}" var="Wrapper" cellpadding="5" id="theTable" rowClasses="odd,even" styleClass="tableClass">

           <apex:column >
                <apex:facet name="header">Sort Order Number</apex:facet>
                <apex:outputText value="{!Wrapper.column1}"/>
                <apex:facet name="footer">{!items}</apex:facet>
          </apex:column>


           <apex:column >
                <apex:facet name="header">Product Name</apex:facet>
                <apex:outputText value="{!Wrapper.column2}"/>
                <apex:facet name="footer">Total</apex:facet>
          </apex:column>
          

          <apex:column style="text-align:right;" >
                <apex:facet name="header">Unit Price</apex:facet>
                <apex:outputtext value="{!if(Wrapper.column3==null,'',Currsign)}{!if(Wrapper.column8=='true','',
                                                    If(len(text(Wrapper.column3))==6, left(text(Wrapper.column3),3)&','&right(text(Wrapper.column3),3),
                                                        If(len(text(Wrapper.column3))==5, left(text(Wrapper.column3),2)&','&right(text(Wrapper.column3),3),
                                                            If(len(text(Wrapper.column3))==4, left(text(Wrapper.column3),1)&','&right(text(Wrapper.column3),3),unit_price))))}"/>
                <apex:facet name="footer">
                <apex:outputPanel id="unitPanel" style="float:right;">
                    {!Currsign}{!If(len(text(unit_price))==6, left(text(unit_price),3)&','&right(text(unit_price),3),
                                If(len(text(unit_price))==5, left(text(unit_price),2)&','&right(text(unit_price),3),
                                If(len(text(unit_price))==4, left(text(unit_price),1)&','&right(text(unit_price),3),unit_price)))}
                </apex:outputpanel></apex:facet>
          </apex:column>
          
          <apex:column style="text-align:right;" >
                <apex:facet name="header">Quantity</apex:facet>
                <apex:outputText value="{!If(right(text(Wrapper.column4),3)=='.00',left(text(Wrapper.column4), Len(text(Wrapper.column4))-3),text(Wrapper.column4))}"/>

          </apex:column>
          
          <apex:column style="text-align:right;" >
                <apex:facet name="header">Cost Each</apex:facet>
                <apex:outputText value="{!if(Wrapper.column5==null,'',Currsign)}{!If(len(text(Wrapper.column5))==6, left(text(Wrapper.column5),3)&','&right(text(Wrapper.column5),3),
                                                        If(len(text(Wrapper.column5))==5, left(text(Wrapper.column5),2)&','&right(text(Wrapper.column5),3),
                                                            If(len(text(Wrapper.column5))==4, left(text(Wrapper.column5),1)&','&right(text(Wrapper.column5),3),Wrapper.column5)))}"/>
                <apex:facet name="footer"><apex:outputPanel id="costPanel" style="float:right;">
                                    {!Currsign}{!If(len(text(round(round(cost, 2), 2)))==6, left(text(round(round(cost, 2), 2)),3)&','&right(text(round(round(cost, 2), 2)),3),
                                If(len(text(round(round(cost, 2), 2)))==5, left(text(round(round(cost, 2), 2)),2)&','&right(text(round(round(cost, 2), 2)),3),
                                If(len(text(round(round(cost, 2), 2)))==4, left(text(round(round(cost, 2), 2)),1)&','&right(text(round(round(cost, 2), 2)),3),round(round(cost, 2), 2))))}
                </apex:outputpanel></apex:facet>
          </apex:column>

          <apex:column style="text-align:right;" >
                <apex:facet name="header">Before Discount FM (%)</apex:facet>
                <apex:outputText value="{!text(round((Wrapper.column3-Wrapper.column5)/Wrapper.column3,4)*100)&if(isnull(Wrapper.column5),'','%')}"/>
                <apex:facet name="footer"><apex:outputPanel id="FMPanel" style="float:right;">
              {!text(round((unit_price-cost)/unit_price*100,2))&'%'}
                </apex:outputpanel></apex:facet>
          </apex:column>
          
          <apex:column style="text-align:right;" >
                <apex:facet name="header">Discount</apex:facet>
                <apex:outputText value="{!If(Wrapper.column6=null,'0.00',Wrapper.column6)}"/>
            <apex:facet name="footer"><apex:outputPanel id="discount" style="float:right;">
              {!round(totaldiscount/unit_price*100,2)}
                </apex:outputpanel></apex:facet>
          </apex:column>  

          <apex:column style="text-align:right;" >
                <apex:facet name="header">After Discount FM %</apex:facet>
                <apex:outputText value="{!text(round((Wrapper.column7-Wrapper.column5)/Wrapper.column7,4)*100)&If(isnull(Wrapper.column5),'','%')}"/>
                 <apex:facet name="footer"><apex:outputPanel id="AfterFMPanel" style="float:right;">
              {!text(round((totalprice-cost)/totalprice*100,2))&'%'}
                </apex:outputpanel></apex:facet>
          </apex:column>  
                                    
          <apex:column style="text-align:right;" >
                <apex:facet name="header">Total Price</apex:facet>
                <apex:outputtext value="{!if(Wrapper.column7==null,'',Currsign)}{!if(Wrapper.column8=='true','',
                                                    If(len(text(Wrapper.column7))==6, left(text(Wrapper.column7),3)&','&right(text(Wrapper.column7),3),
                                                        If(len(text(Wrapper.column7))==5, left(text(Wrapper.column7),2)&','&right(text(Wrapper.column7),3),
                                                            If(len(text(Wrapper.column7))==4, left(text(Wrapper.column7),1)&','&right(text(Wrapper.column7),3),unit_price))))}"/>
                <apex:facet name="footer"><apex:outputPanel id="datePanel" style="float:right;">
                    {!Currsign}{!If(len(text(totalprice))==6, left(text(totalprice),3)&','&right(text(totalprice),3),
                                If(len(text(totalprice))==5, left(text(totalprice),2)&','&right(text(totalprice),3),
                                If(len(text(totalprice))==4, left(text(totalprice),1)&','&right(text(totalprice),3),totalprice)))}
                </apex:outputpanel></apex:facet>
          </apex:column>

    </apex:dataTable>

    </apex:pageBlock>
    </apex:form>
</apex:page>

How do I solve the problem?

Thank you,

 
The auto complete does not render suggested choices when the inputtext field is in a pageblock, but renders suggestions as intended when it is not in a page block. How can I solve this problem. Below is my visualforce and apex code.
 
Visualforce page:

<apex:page Controller="AddmultipleCPLIController"  docType="html-5.0">
    <!--Make sure you have the Javascript in the same order that I have listed below.-->
    <script src="https://code.jquery.com/jquery-1.8.2.js"></script>
    <script src="/soap/ajax/26.0/connection.js" type="text/javascript"></script>
    <script src="https://code.jquery.com/ui/1.9.0/jquery-ui.js"></script>
    <link rel="stylesheet" href="https://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css"/>
    <script type="text/javascript">
        var j$ = jQuery.noConflict();
        var apexAccountList =[];
         
        //use the <!-- <apex:repeat > -->tag to iterate through the list returned from the class and store only the names in the javascript variable.
        <apex:repeat value="{!CustomerProductName}" var="accList">
            //Store the name of the account in the array variable.
            apexAccountList.push('{!accList.name}');
        </apex:repeat>
         function changeToText(){
           var currSelected = document.getElementsByClassName("keypad");
           for (var i=0; i< currSelected.length;i++) {
                  currSelected[i].type = 'text';
   }
}
    
       //on Document ready
        j$(document).ready(function(){
             
            j$("#apexaccountautocomplete").autocomplete({
                source : apexAccountList
            });

        });
    </script>
     
    <apex:form id="form1" >
    <apex:pageBlock id="block1">
        <apex:pageBlockButtons >
            <apex:commandButton value="Add Customer Product Row" action="{!addCPLI}"/>
            <apex:commandButton value="Save Customer Product" action="{!saveCPLI}"/>
        </apex:pageBlockButtons>

    <apex:pageblockTable value="{!listcpli}" var="cpli" id="pbt">
        <apex:column headerValue="Customer Product Name" id="c1">
            <apex:inputText styleClass="keypad" onfocus="changeToText()" id="apexaccountautocomplete" required="true" />
        </apex:column>

    </apex:pageblockTable>
 

    </apex:pageBlock>
</apex:form>
</apex:page>
Apex Class:

public class AddmultipleCPLIController {

    public list<Customer_Product__c> getCustomerProductName() {
        return [select id,name from Customer_Product__c limit 25];
    }

    // Instance fields
    public String searchTerm {get; set;}
    public String selectedMovie {get; set;}
    
    // JS Remoting action called when searching for a movie name
   @RemoteAction
    public static List<Customer_Product__c> searchMovie(String searchTerm) {
        System.debug('Movie Name is: '+searchTerm );
        List<Customer_Product__c> movies = Database.query('Select Id, Name from Customer_Product__c where name like \'%' + String.escapeSingleQuotes(searchTerm) + '%\'');
        return movies;
    }
    Customer_Product_Line_Item__c cpli = new Customer_Product_Line_Item__c();
    public list<Customer_Product_Line_Item__c> listcpli{ get; set; }

    public AddmultipleCPLIController()
        {
            listcpli=new list<Customer_Product_Line_Item__c>();
            listcpli.add(cpli);
        }

    Public void addCPLI()
        {
            Customer_Product_Line_Item__c acc = new Customer_Product_Line_Item__c();
            listcpli.add(acc);
        }

    public PageReference saveCPLI() {
       for(Integer i=0; i<listcpli.size(); i++)
        {
        insert listcpli;
            }
        return null;
    }

}


How can I solve this problem?
The below code has auto complete being used in a pageblocktable. I can make the auto complete work outside of the pageblocktable, but not inside the table. What changes do I need to make in my code?

VFpage
<apex:page Controller="AddmultipleCPLIController">
    <!--Make sure you have the Javascript in the same order that I have listed below.-->
    <script src="https://code.jquery.com/jquery-1.8.2.js"></script>
    <script src="/soap/ajax/26.0/connection.js" type="text/javascript"></script>
    <script src="https://code.jquery.com/ui/1.9.0/jquery-ui.js"></script>
    <link rel="stylesheet" href="https://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css"/>
    <script type="text/javascript">
        var j$ = jQuery.noConflict();
        var apexAccountList =[];
         
        //use the <!-- <apex:repeat > -->tag to iterate through the list returned from the class and store only the names in the javascript variable.
        <apex:repeat value="{!CustomerProductName}" var="accList">
            //Store the name of the account in the array variable.
            apexAccountList.push('{!accList.name}');
        </apex:repeat>
         
        //We will establish a connection salesforce database using the sforce.connection.init(sessionID, ServerURL) function.
        var sid = '{!$Api.Session_ID}';
        var server = "https://" + window.location.host + "/services/Soap/u/26.0";
        sforce.connection.init(sid, server);
         
        //We will query the contact object using the sforce.connection.query function. This will return 200 results.
        var result = sforce.connection.query("select Name from Customer_Product__c");
        var records = result.getArray("records");
    
       //on Document ready
        j$(document).ready(function(){
             
            j$("#NameAC").autocomplete({
                source : apexAccountList
            });

        });
    </script>
<apex:form > 

    <apex:pageBlock >
        <apex:pageBlockButtons >
            <apex:commandButton value="Add Customer Product Row" action="{!addCPLI}"/>
            <apex:commandButton value="Save Customer Product" action="{!saveCPLI}"/>
        </apex:pageBlockButtons>

    <apex:pageblockTable value="{!listcpli}" var="cpli" id="pbt">
        <apex:column headerValue="Customer Product Name">
            <apex:inputField value="{!cpli.name}" id="NameAC" required="true"/>
        </apex:column>

    </apex:pageblockTable>
 

    </apex:pageBlock>
</apex:form>
</apex:page>
Below is the class:
public class AddmultipleCPLIController {

    public list<Customer_Product__c> getCustomerProductName() {
        return [select id,name from Customer_Product__c limit 25];
    }


    Customer_Product_Line_Item__c cpli = new Customer_Product_Line_Item__c();
    public list<Customer_Product_Line_Item__c> listcpli{ get; set; }

    public AddmultipleCPLIController()
        {
            listcpli=new list<Customer_Product_Line_Item__c>();
            listcpli.add(cpli);
        }

    Public void addCPLI()
        {
            Customer_Product_Line_Item__c acc = new Customer_Product_Line_Item__c();
            listcpli.add(acc);
        }

    public PageReference saveCPLI() {
       for(Integer i=0; i<listcpli.size(); i++)
        {
        insert listcpli;
            }
        return null;
    }

}


 
The below code combines two lists as one list and sorts the list.
public with sharing class ProductCostSalesSheet {


    public ProductCostSalesSheet() {
        o = [select id from Opportunity where id =: System.currentpageReference().getParameters().get('oppid')];
        system.debug('*********************000000000:'+ o); 
        oppi = o.id;  
        system.debug('*********************000000001:'+ oppi); 
        
    }

    
    id oppi;
    Public final Opportunity o;
    List<String> prodOption = new List<String>();
    Map<String, String> joinMap = new Map<String, String>();

    public ProductCostSalesSheet(ApexPages.StandardController controller) {
        
        }

      public  List<string> getOppProductOptions(){
      
      prodOption = new List<String>();
      

       for(OpportunityLineItem oli: [select id, Product2.name, unitprice, discount, totalprice, quantity from OpportunityLineItem where OpportunityId =: oppi]){
           joinMap.put(oli.id, oli.id+','+oli.product2.name+','+oli.quantity+','+oli.discount+','+oli.unitprice);
       }
       
       for(Proposal_Option__c p : [select id, Opportunity_Product__c, Description__c,sequence__c,sales_price__c,discount__c,unit_price__c,quantity__c from Proposal_Option__c where Opportunity__c =: oppi]){
           joinMap.put(p.Opportunity_Product__c+p.id, p.Opportunity_Product__c+p.sequence__c+','+p.Description__c+','+p.quantity__c+','+p.discount__c+','+p.unit_price__c);
           system.debug('*********************000000003:'+ joinMap); 
       }
       prodOption = joinMap.values();
      
       prodOption.sort();
    
       return prodOption;
    }

}
The code does the following:
1. Joins mulitple fields into one comma-separated string.
2. Combines two lists into a map, then a list.
3. Sorts the list.
4. returns the list.

How do I now convert the comma-separated string to a list?
 
I am depolying the partner community and have found that my visualforce page buttons and links do not work in the communities. I need to write this link to work in any community and the standard Salesforce UI:

/apex/quoterequestredirectguidance?oppid=' + oppid + '&CANCELurl=/' + oppid

In communities I have learned that the url needs to start with the community name as in:
<community name>/quoterequestredirectguidance?oppid=' + oppid + '&CANCELurl=/' + oppid

How do I write the above link where the apex code will determinet whether the user is in a community or the standard ui, then insert the correct label in url? Ideally I would like to create one link that will work in any community or non-community environment?

Thank you
I am in a project where i have to update all my test classes in my org with the new fields I am creating. A huge time commitment. What is best practice for apex code? Should I configure one class where I have create my test class records or create the test data in each test class? This affects 50+ test classes in my org.
I need to test a validation rule in my test class where the formula field is a date field. From my research, I have developed the code below:

General_Spec_Sheet__c gss2 = new General_Spec_Sheet__c(
       
                            name = 'General Spec Sheet',
                            Opportunity__c = op.id,
                            Customer_Account__c = a.id,
                            Update_Invoice_Billing_Address__c = 'yes',
                            Invoice_to_street__c = '1232 SW Broadway',
                            Invoice_to_City__c = 'Anytown',
                            Invoice_to_State__c = 'AnyState',
                            Invoice_to_Country__c = 'Canada',
                            Invoice_to_Zip_Postal_Code__c = '12345',
                            Technical_Contact__c = con.id,
                            Commercial_Contact__c = con.id,
                            e_mail__c = 'jo@doe.com',
                            phone__c = '5565656456',
                            Update_Technical_Contact_Record__c = 'yes',//Monica
                            Update_Commercial_Contact_Record__c = 'Yes',
                            update__c = 'yes',// Monica
                            Customer_Specific_Standards__c = 'No',
                            fax__c = '1234567898',
                            Generate_Firm_Budget_Quote__c = 'Budget Quote',
                            Requested_Date_to_Complete_Quote__c = date.parse('1/1/2020'));
        try{
             insert gss2;
   

       } Catch(Exception E){
      
       }
    General_Spec_Sheet__c gs = [select id, X3_Day_Minimum_Quote_Due_Date__c from General_Spec_Sheet__c where id=:gss2.id];
     system.debug(' Status Formula Field : ' + gs.X3_Day_Minimum_Quote_Due_Date__c );
     System.assert(gs.X3_Day_Minimum_Quote_Due_Date__c);

I am not able to retrieve the formula value to ttest the validation rule/ How do I retrieve the formula value?

Thank you
ckellie




Below is my entire test class for further reference::

@isTest(SeeAllData=True)
private class TestCreateGeneralSpecSheetListEdit{
   Static CreateGeneralSpecSheetListEdit ext;
   static testMethod void CreateGeneralSpecSheetListEdit () {

    //Setup User
    User u1 = new user (Username = ' test5462@key.net',
                        alias='test',
                        LastName ='test',
                        email='test@key.net',
                        communityNickname='test',
                        TimeZoneSidKey='America/Los_Angeles',
                        LocaleSidKey='en_US',
                        EmailEncodingKey='ISO-8859-1',
                        ProfileId='00e30000000gAkF',
                        LanguageLocaleKey='en_US' );
    insert u1;
         System.runAs(u1) {
         // The following code runs as user 'u1' 
   
         System.debug('Current User: ' + UserInfo.getUserName());
         System.debug('Current Profile: ' + UserInfo.getProfileId()); }

    u1 = [select id from user where alias = 'test'];
   
    //Run as U1

        Test.startTest();
        Account a = new account ( name = 'accounttest', type = 'customer',
        Strategic_Industry__c = 'POT(Potato)', Strategic_Segment__c= 'Chips',
        Strategic_Product__c = 'Kettle chips', billingstreet = '123 south college ave',
        billingcity = 'College Place', billingstate='Washington', billingcountry='United States of America', billingpostalcode ='99324');
        Insert a;
       
        Campaign campaign = new Campaign (name = 'test');
        insert campaign;
       
        Opportunity op = new Opportunity (Recordtypeid = '012300000000Vnm',
                                            Name = 'opportunitytest',
                                            accountid=a.id, //monica
                                            stagename = 'Budget',
                                            CloseDate = date.parse('1/1/2020'),
                                            Amount = 5.00,
                                            INCO_Terms__c = 'FCA',
                                            Campaignid= campaign.id,
                                            Related_Location__c = 'Walla Walla',
                                            Probability_Key_Will_Win_Order__c = 0.01,
                                            ForecastCategoryName = 'Pipeline',
                                            Equip_Services_Options_to_be_quoted__c = 'tegra',
                                            Op_Market_Position__c = '1 - Existing Equip - Existing App/Market (PB items a known app and current cust base)',
                                            Product_1__c = 'apple',
                                            Product1_Condition__c = 'raw',
                                            Product1_Line_Capacity__c = '20000 lbs/hr',
                                            Ready_to_generate_Quote__c = true,
                                            Ready_to_Generate_a_Budget_Quote__c = true,
                                            Requested_date_to_complete_Quote__c = date.parse('1/1/2020'));
        Insert op;
       
        Contact con = new Contact(
                            lastname = 'Doe',
                            Firstname = 'John',
                            email = 'John@does.com',
                            accountid = a.id);
       
        insert con;
    
      
       Customer_Product__c cp = new Customer_Product__c (name ='Apple');
       
        insert cp;
            
        Customer_Product_Line_Item__c cpli = new Customer_Product_Line_Item__c(
                                            name = 'Apple',
                                            customer_Product__c = cp.id,
                                            Opportunity__c = op.id,
                                            Account__c = a.id,
                                            Condition_1__c = 'Raw',
                                            industry_segment__c = 'Pet Food');
       
         insert cpli;

                General_Spec_Sheet__c gss2 = new General_Spec_Sheet__c(
       
                            name = 'General Spec Sheet',
                            Opportunity__c = op.id,
                            Customer_Account__c = a.id,
                            Update_Invoice_Billing_Address__c = 'yes',
                            Invoice_to_street__c = '1232 SW Broadway',
                            Invoice_to_City__c = 'Anytown',
                            Invoice_to_State__c = 'AnyState',
                            Invoice_to_Country__c = 'Canada',
                            Invoice_to_Zip_Postal_Code__c = '12345',
                            Technical_Contact__c = con.id,
                            Commercial_Contact__c = con.id,
                            e_mail__c = 'jo@doe.com',
                            phone__c = '5565656456',
                            Update_Technical_Contact_Record__c = 'yes',//Monica
                            Update_Commercial_Contact_Record__c = 'Yes',
                            update__c = 'yes',// Monica
                            Customer_Specific_Standards__c = 'No',
                            fax__c = '1234567898',
                            Generate_Firm_Budget_Quote__c = 'Budget Quote',
                            Requested_Date_to_Complete_Quote__c = date.parse('1/1/2020'));
        try{
             insert gss2;
   

       } Catch(Exception E){
      
       }
    General_Spec_Sheet__c gs = [select id, X3_Day_Minimum_Quote_Due_Date__c from General_Spec_Sheet__c where id=:gss2.id];
     system.debug(' Status Formula Field : ' + gs.X3_Day_Minimum_Quote_Due_Date__c );
     System.assert(gs.X3_Day_Minimum_Quote_Due_Date__c);

      for(account acct : [select id from account where id =:a.id]){
               if(gss2.Update_Invoice_Billing_Address__c == 'yes'){
               acct.billingstreet = gss2.Invoice_to_street__c;
               acct.billingcity = gss2.Invoice_to_City__c;
               acct.billingstate = gss2.Invoice_to_State__c;
               acct.billingcountry = gss2.Invoice_to_Country__c;
               acct.billingpostalcode = gss2.Invoice_to_Zip_Postal_Code__c;
           update acct;}
          
            system.assertEquals('1232 SW Broadway', acct.billingstreet);
          
           }
        
     Task ta = new Task (
         whatid = op.id,
         subject='Generate a Budget Quote - U.S./Canada',
         ActivityDate = gss2.Requested_Date_to_Complete_Quote__c,
         ownerid= u1.id);
          
           insert ta;
            
      PageReference pageRef2 = Page.GeneralSpecSheetEdit;
   
    pageRef2.getParameters().put('id', gss2.id);

    Test.setCurrentPageReference(pageRef2);
              

        Test.stopTest();
      
                         
        ApexPages.StandardController sc = new ApexPages.StandardController(New General_Spec_Sheet__c());   
      
                           ext = new CreateGeneralSpecSheetListEdit(sc );          
   
   
     String cpUrl = '/apex/GeneralSpecSheetEdit?id=' + gss2.id;

       
        ext.getgess();
        ext.getresults();
        ext.EditGS();
        ext.SendUpdatesandTask();
        ext.CanceltoManage();


           }
   
}
In this class, i am updating the related opportunity record and sending a task to the product specialist listed on the opportunity team.

This list is not returning any records although I have confirmed a record is created that meets the criteria:

List<OpportunityTeamMember> uotm = [SELECT Id, OpportunityId, TeamMemberRole, UserId FROM OpportunityTeamMember where TeamMemberRole = 'Product Specialist' and OpportunityID =: oid];

How do I correct the query to capture the record in the list?


The complete class:

public with sharing class CreateGeneralSpecSheetListEdit{

    public CreateGeneralSpecSheetListEdit() {

    }

    ApexPages.StandardController GstdController;
    id oid;
    id aid;
    id gid;
    id eid;
    id tid;
    id cid;
    public List<Customer_Product_Line_Item__c> cpList {get; set;}
    public General_Spec_Sheet__c genss;
   
    public CreateGeneralSpecSheetListEdit(ApexPages.StandardController controller) {

       gid = [select id from General_Spec_Sheet__c Where id =:ApexPages.currentPage().getParameters().get('genid') or id =:ApexPages.currentPage().getParameters().get('id')].id;
       tid = [select Technical_Contact__r.id from General_Spec_Sheet__c Where id =:ApexPages.currentPage().getParameters().get('genid') or id =:ApexPages.currentPage().getParameters().get('id')].Technical_Contact__r.id;
       cid = [select Commercial_Contact__r.id from General_Spec_Sheet__c Where id =:ApexPages.currentPage().getParameters().get('genid') or id =:ApexPages.currentPage().getParameters().get('id')].Commercial_Contact__r.id;
       oid = [select Opportunity__r.id, Opportunity__r.Accountid from General_Spec_Sheet__c Where id =:ApexPages.currentPage().getParameters().get('genid') or id =:ApexPages.currentPage().getParameters().get('id')].Opportunity__r.id;
       aid = [select Opportunity__r.Accountid from General_Spec_Sheet__c Where id =:ApexPages.currentPage().getParameters().get('genid') or id =:ApexPages.currentPage().getParameters().get('id')].Opportunity__r.Accountid;
        GstdController = controller;
  
    this.genss = (General_Spec_Sheet__c)GstdController.getRecord();

    }

    public List<Customer_Product_Line_Item__c> getresults() {
        if(cplist == null) {
            cplist = new List<Customer_Product_Line_Item__c>();
            for(Customer_Product_Line_Item__c c: [select id, Name, Opportunity__c, Opportunity__r.SFDC_for_Quote__c,Opportunity__r.AIS__c,
                    Condition_1__c, Condition_2__c, Condition_3__c, Temperature_deg_f__c, Capacity__c, General_Application__c, Shape_1__c,
                    Shape_2__c, Defect_Description__c, Environment_temp_f__c, Capacity_per_lane__c, bulk_density__c, Opportunity__r.PS__c from
                    Customer_Product_Line_Item__c where Opportunity__c =: oid]) {

                cplist.add(c);
            }
        }
        return cplist;
    }

    public PageReference EditGS(){
     
   
   PageReference pageRef = new PageReference('/apex/GeneralSpecSheetEdit?genid=' + gid + '&sfdc.override=1');
         pageRef.setRedirect(true);

    return pageRef;
    }


    List<Opportunity> opp = [select id, Ready_to_Generate_new_Firm_Quote__c, Ready_to_Generate_a_Budget_Quote__c,Requested_date_to_complete_Firm_Quote__c,
                            sfdc_for_quote__c, Opportunity_Region__c, Requested_date_to_complete_Budget_Quote__c from Opportunity where id=:oid];
   
    list<Account> acct = [select id from account where id =: aid];
   
    id eotm = [select id from user where name = 'Sander van Heumann'].id;
    List<OpportunityTeamMember> uotm = [SELECT Id, OpportunityId, TeamMemberRole, UserId FROM OpportunityTeamMember where OpportunityID =: oid];

    public PageReference SaveList(){

        update cplist;

    PageReference pr = GstdController.save();

     If(genss.Update_Invoice_Billing_Address__c == 'Yes'){
         acct[0].BillingStreet = genss.Invoice_to_Street__c;
         acct[0].BillingCity = genss.Invoice_to_City__c;
         acct[0].BillingCountry = genss.Invoice_to_Country__c;
         acct[0].BillingPostalCode = genss.Invoice_to_Zip_Postal_Code__c;

        genss.Update_Invoice_Billing_Address__c = 'Updated';

     }

     If(genss.Update__c == 'yes'){
         acct[0].ShippingStreet = genss.Ship_To_Street__c;
         acct[0].ShippingCity = genss.Ship_to_City__c;
         acct[0].ShippingState = genss.Invoice_to_State__c;
         acct[0].ShippingCountry = genss.Invoice_to_Country__c;
         acct[0].ShippingPostalCode = genss.Invoice_to_Zip_Postal_Code__c;
       
        genss.Update__c = 'Updated';
    
        }

     update acct;
    
    List<Contact> com = new List<Contact>([select id from contact where id =: cid]);
    for(Contact co : com){
       if(genss.Update_Commercial_Contact_Record__c == 'Yes'){
         co.mailingstreet = genss.commercial_contact_street__c;
         co.mailingcity = genss.commercial_contact_city__c;
         co.mailingstate = genss.commercial_contact_state__c;
         co.mailingcountry = genss.commercial_contact_country__c;
         co.mailingpostalcode = genss.commercial_contact_zip_postal_code__c;
         co.phone = genss.phone__c;
         co.email = genss.e_mail__c;
         co.title = genss.title__c;
         co.fax = genss.fax__c;
        
         genss.Update_Technical_Contact_Record__c = 'Updated';
      

     update co;
        }
        }
    for(Opportunity o : [select id, Opportunity_Region__c, Ready_to_Generate_new_Firm_Quote__c, Requested_date_to_complete_Budget_Quote__c,
                            Ready_to_generate_a_Budget_Quote__c, Requested_date_to_complete_Firm_Quote__c from Opportunity where id =:oid]){
     o.Ready_to_Generate_a_Budget_Quote__c = genss.opportunity__r.Ready_to_Generate_a_Budget_Quote__c;
     o.Requested_date_to_complete_Budget_Quote__c = genss.opportunity__r.Requested_date_to_complete_Budget_Quote__c;
     o.Ready_to_Generate_new_Firm_Quote__c = genss.opportunity__r.Ready_to_Generate_new_Firm_Quote__c;
     o.Requested_date_to_complete_Firm_Quote__c = genss.opportunity__r.Requested_date_to_complete_Firm_Quote__c;
         

       
         Task ta = new Task();
           ta.whatID = o.id;
           ta.ActivityDate= o.Requested_date_to_complete_Firm_Quote__c;
               If(o.Opportunity_region__c == 'Europe' && o.Ready_to_Generate_new_Firm_Quote__c == true ){
                   ta.subject='Generate a Firm Quote - Europe';}
               If(o.Opportunity_region__c == 'Europe' && o.Ready_to_Generate_a_Budget_Quote__c == true ){
                   ta.subject='Generate a Budget Quote - Europe';}
               If(o.Opportunity_region__c <> 'Europe' && o.Ready_to_Generate_new_Firm_Quote__c == true ){
                   ta.subject='Generate a Firm Quote - U.S./Canada';}
               If(o.Opportunity_region__c <> 'Europe' && o.Ready_to_Generate_a_Budget_Quote__c == true ){
                   ta.subject='Generate a Budget Quote - U.S./Canada';}
           ta.Agreed_due_date__c = o.Requested_date_to_complete_Firm_Quote__c;
               If(o.Opportunity_region__c == 'Europe'){
                   ta.ownerid= eotm;}
               else{ta.ownerid= uotm[0].id;}
        Database.DMLOptions dmlo1 = new Database.DMLOptions();
        dmlo1.EmailHeader.triggerUserEmail = true;
        database.insert(ta, dmlo1);
        }
      
   PageReference pageRef = new PageReference('/apex/GeneralSpecSheetView?id='+gid+'&genid='+gid);
         pageRef.setRedirect(true);

    return pageRef;
    }

 
    public PageReference CanceltoOpp(){
   
   PageReference pageRef = new PageReference('/'+oid);
         pageRef.setRedirect(true);

    return pageRef;
    }   
 
    public PageReference CanceltoManage(){
   
   PageReference pageRef = new PageReference('/apex/GeneralSpecSheetView?id='+gid+'&genid='+gid);
         pageRef.setRedirect(true);

    return pageRef;
    }   
}

Thank you
I currently am updating a custom object's strategic industry based on the user choosing the industry segment, then apex code is looking up the coorrelating strategic industry. Below is the code

Map<string, Industry_Definition__c> imap = new Map<string, Industry_Definition__c>();
   
    for(Industry_Definition__c i : [select id, Market_Segment__c, Strategic_Industry__c from Industry_Definition__c]){
        imap.put(i.Market_Segment__c, i);
        system.debug('##########i.Market_segment__c:'+ i.market_segment__c);
    }
                     
     for( Integer i = 0; i < Trigger.new.size(); i++){
            trigger.new[i].Strategic_Industry__c = imap.get(trigger.new[i].industry_Segment__c).Strategic_Industry__c;
    }

I need to extend thefunctionality to populate the strategic industry on the related account with the same value as the strategic industry on the trigger.new record. I am trying to use the code below to update the account strategic industry
Map<id, Customer_Product_Line_Item__c> cmap = new Map<id, Customer_Product_Line_Item__c>(Trigger.new);
   
    Account[] relatedaccount = new List<Account>(); relatedaccount = [select id, Strategic_Industry__c from account
        where id in:cmap.keyset()];

    for(Account a : relatedaccount){
        a.Strategic_Industry__c = imap.get(cmap.industry_segment__c).Strategic_Industry__c;
    }

The above code is returning the following error:
Error: Compile Error: Initial term of field expression must be a concrete SObject: MAP<Id,Customer_Product_Line_Item__c> at line 20 column 44


Here is the entire trigger:
trigger IndustrytoAcctOpp on Customer_Product_Line_Item__c (Before Insert, Before Update) {

    Map<string, Industry_Definition__c> imap = new Map<string, Industry_Definition__c>();
   
    for(Industry_Definition__c i : [select id, Market_Segment__c, Strategic_Industry__c from Industry_Definition__c]){
        imap.put(i.Market_Segment__c, i);
        system.debug('##########i.Market_segment__c:'+ i.market_segment__c);
    }
                     
     for( Integer i = 0; i < Trigger.new.size(); i++){
            trigger.new[i].Strategic_Industry__c = imap.get(trigger.new[i].industry_Segment__c).Strategic_Industry__c;
    }
   
    Map<id, Customer_Product_Line_Item__c> cmap = new Map<id, Customer_Product_Line_Item__c>(Trigger.new);
   
    Account[] relatedaccount = new List<Account>(); relatedaccount = [select id, Strategic_Industry__c from account
        where id in:cmap.keyset()];

    for(Account a : relatedaccount){
        a.Strategic_Industry__c = imap.get(cmap.industry_segment__c).Strategic_Industry__c;
    }

}

How do I solve this problem?
Thank you
Is there a way to allow the end user to login directly to Salesforce while basing my network as the identity provider? Would someone supply a link with a simplistic example?
I have a business process managed with workflow rules that I an debating using apex code for but don't know which way to proceed. Currently I have aproximately 80 workflow rules and 100 field updates active on one object too write a description of the record when the record is created and updated. These field updates are updating a string of text fields. In another automation the text fields are concatenated updated into a long text field to form a bulletted list.

I now need to combine both processes into one, where the logic from the workflow rules and field updates will run and update the long text field. Although I have been programming for years, this is the largest project that I have tackled. Would anyone advise me on how to structure this project to run the most efficiently and allow for the best maintanence?

Thank you
How do I add three buttons on a javascript alert driven by a custom button? In my use case, I want to notify the user that not all data is entered on the opportunity page, but give the user the option to continue create a quote without the data, or return to the opportunity to add the information.

Below is the custom button:
REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
{!REQUIRESCRIPT('/soap/ajax/29.0/apex.js')}
var result = sforce.connection.query("SELECT id, opportunityid, role from OpportunityContactRole where opportunityid = '{!Opportunity.Id}' and role='Technical Contact'");
var records = result.getArray("records");

var error1string = "Error:\n";
var error1found = false;
if(!records[0]==null) {
error1string += "The technical contact is not listed on the Opportunity nor will be listed on the budget proposal. Please add the technical contact to contact roles.";
error1found = true;
}


if(records[0]==null) {
alert("The technical contact is not listed on the Opportunity nor will be listed on the budget proposal. Do you want to continue to create the quote or do you want to add the technical contact?");
window.location = "{!URLFOR($Action.Opportunity.View,Opportunity.Id)}";
} else {
/apex/QuoteNotification?oppid={!Opportunity.Id}&Type="B"&Rec="Budget Quote"
}

How do I add two buttons to the alert?
I have created the following dynamic picklist.
for(firepond__Configurable__c prod : [select id, name, firepond__Item_Id__r.name, firepond__Item_Id__c, firepond__Item_Id__r.Salesforce_Product__r.name, firepond__Item_Id__r.Salesforce_Product__r.id, firepond__Item_Id__r.firepond__Description__c, 
                                                                firepond__RecordType__c from firepond__Configurable__c where firepond__RecordType__c = 'Product'
                                                                and firepond__Item_Id__c<>'' and (Not firepond__Item_Id__r.name like '%Veryx%')]) {
                    
                    productNamesMap.put(prod.Id, prod.firepond__Item_Id__r.firepond__Description__c);
                    productIdsMap.put(prod.firepond__Item_Id__r.firepond__Description__c, prod.Id);
                    FPXProd.add(prod.firepond__Item_Id__r.Salesforce_Product__r.name);
                        }             
                    if(productNamesMap != null){
                    productNamesList = productNamesMap.values();
                    }

        for(Product2 prod : [ select id, name from product2 where not(name =:FPXprod)]){
                    productNamesList.add(prod.name);
                    produc
The end user can filter this picklist by typing keywords in the text field. If the end user selects a value without filtering the picklist, the system will not return the currect selected value. But if the user filters the picklist to a few values, they will recieve the selected value. Why does the size of the picklist affects whether the system will return the value the user selects?

Thanks,
ckellie
 
The below code is perplexing me. The concept is to look up the default account's language and return it to the Opportunity. The opportunity's language is note being updated. Below is the code:
public class DefaultOpportunityLanguage{
  // These variables store Trigger.oldMap and Trigger.newMap
   Map<Id, Opportunity> oldOpps;
   Map<Id, Opportunity> newOpps;
   Map<Id, Account> accmap = new Map<Id, Account>();
   Set<id> aid = new Set<id>();
   Set<id> oid = new Set<id>();
   String scountry;
   
  // This is the constructor
  // A map of the old and new records is expected as inputs
  public DefaultOpportunityLanguage(
    Map<Id, Opportunity> oldTriggerOpps, 
    Map<Id, Opportunity> newTriggerOpps) {
      oldOpps = oldTriggerOpps;
      newOpps = newTriggerOpps;
  }

  // The one method your master trigger will call
  public void DefaultOpportunityLanguage() {
    string u = 'Angola';
    Map<string, pw_cc__CountryObject__c> countrymap = new Map<string, pw_cc__CountryObject__c>();
    
    for(pw_cc__CountryObject__c p : [select name,Primary_Language__c from pw_cc__CountryObject__c]){
      countrymap.put(p.name, p);
    }
    system.debug('*************5countrymap size:' +countrymap.size());    
    
    for (Opportunity newOpp : oldOpps.values()) {
            system.debug('*************1accountid:' +newOpp.accountid);
            aid.add(newOpp.accountid);
            oid.add(newOpp.id);
            
  } 
      for(account a : [select id, shippingcountry from account where id in:aid]){
          accMap.put(a.id,a);
      }

    for (Opportunity newOpp : [select id, accountid, Language_to_prepare_docs_in__c from Opportunity where id =: oid]) {
        system.debug('*************3id:' +newOpp.id);

           scountry = accMap.get(newOpp.accountid).shippingCountry;
            system.debug('*************4scountry:' +scountry);
            if(countrymap.get(scountry).Primary_Language__c<>''){
               newOpp.Language_to_prepare_docs_in__c = countrymap.get(scountry).Primary_Language__c;

           scountry = '';
         }
  } 
  
 }
}
The variable scountry is populated, the countrymap is populated, and I have confirmed that the database is complete with the appropriate records. But the language is not being written back tothe opportunity.
 
I have a list of checkboxes in a wrapper class/pageblocktable that I want to limit the user to only choose one box.

Below is my script
function checkone(cb,conid)
{

   var inputElem = document.getElementsByTagName("input");
    for(var i=1; i<inputElem.length; i++)
    {
        if(inputElem[i].id.indexOf("checkedone")!=-1)
        {
            if(inputElem[i].name!=cb.name)
            {
                inputElem[i].checked=false;
            }
        }
    }
  
  
}

This automation is working great if I assign the checkbox to the records id and not the selected element:
<input type="checkbox" name="{!cp.con.id}" id="checkedone"  onclick="return checkone(this,'{!cp.con.id}')"  />

but when I use the selected element of the wrapper class the automation does not work.
<input type="checkbox" name="{!cp.selected}" id="checkedone"  onclick="return checkone(this,'{!cp.selected}')"  />

How do I change my function to control cp.selected, or change my wrapper class to process cp.con.id when the checkbox is selected? Below is my visualforce page and apex class

VFpage:
<apex:page standardcontroller="App_Matrix__c" extensions="ApplicationDefiner" tabStyle="App_Matrix__c" sidebar="false" showChat="false">
<script>
function checkone(cb,conid)
{

   var inputElem = document.getElementsByTagName("input");
    for(var i=1; i<inputElem.length; i++)
    {
        if(inputElem[i].id.indexOf("checkedone")!=-1)
        {
            if(inputElem[i].name!=cb.name)
            {
                inputElem[i].checked=false;
            }
        }
    }
  
  
}
</script>  

    <apex:sectionHeader title="Application Solution"/>
<apex:form >

    <apex:pageBlock title="Select Primary Application" mode="view"> 
           <apex:pageBlockButtons >
                <apex:commandButton value="Process Selected" action="{!processSelected}" rerender="resultTemtbl" />
            </apex:pageBlockButtons>
       <apex:pageblockTable value="{!CProduct}" title="Select Primary Application" var="cp" id="pbselecttbl">

       <apex:column headerValue="Primary Application" width="50px">

       <input type="checkbox" name="{!cp.selected}" id="checkedone"  onclick="return checkone(this,'{!cp.selected}')"  />
       <!--    <input type="checkbox" name="{!cp.con.id}" id="checkedone"  onclick="return checkone(this,'{!cp.con.id}')"  />  -->
        </apex:column>
           <apex:column value="{!cp.con.name}" headerValue="Name" width="60px"/>
           <apex:column value="{!cp.con.Condition_1__c}" headerValue="Primary Condition" width="60px"/>
           <apex:column value="{!cp.con.Condition_2__c}" headerValue="Additional Condition" width="60px"/>
           <apex:column value="{!cp.con.Shape_1__c}" headerValue="Primary Shape" width="60px"/>
           <apex:column value="{!cp.con.Shape_2__c}" headerValue="Additional Shape" width="60px"/>
           <apex:column value="{!cp.con.Defect_Description__c}" headerValue="Sort Criteria"/>
       
       </apex:pageblockTable><br/><br/>
    </apex:pageBlock><br/><br/> 
    <apex:pageBlock title="Template ID" mode="view" >  
       <apex:pageblockTable value="{!Configuration}" Title="Template ID" var="cp" id="resultTemtbl">

           <apex:column value="{!cp.name}" headerValue="Template ID" width="30px"/>
           <apex:column value="{!cp.Base_Model__c}" headerValue="Base Model" width="30px"/>
           <apex:column value="{!cp.Customer_Product__r.name}" headerValue="Name" width="40px"/>
           <apex:column value="{!cp.Condition_1__c}" headerValue="Primary Condition" width="60px"/>
           <apex:column value="{!cp.Condition_2__c}" headerValue="Additional Condition" width="60px"/>
           <apex:column value="{!cp.Shape_1__c}" headerValue="Primary Shape" width="60px"/>
           <apex:column value="{!cp.Shape_2__c}" headerValue="Additional Shape" width="60px"/>
           <apex:column value="{!cp.Defect_Description__c}" headerValue="Sort Criteria"/>
       
       </apex:pageblockTable>

    </apex:pageBlock>

</apex:form>
</apex:page>
Apex Class:
public with sharing class ApplicationDefiner {

    public ApplicationDefiner(ApexPages.StandardController controller) {
  oid =[SELECT id from Opportunity WHERE id =:ApexPages.currentPage().getParameters().get('oppid')].id;

    }

    id oid;
    public List<cCustomer> cpList {get; set;}
    public List<App_Matrix__c> aplist {get; set;}
    Boolean cpprimary;
    List<Customer_Product_Line_Item__c> selectedCpli = new List<Customer_Product_Line_Item__c>();
    Public Map<string, App_Matrix__c> apmap = new Map<string, App_Matrix__c>();
    Set<String> cpset = new Set<String>();
    Set<String> cpprimaryset = new Set<String>();


    public List<cCustomer> getCProduct() {
            cplist = new List<cCustomer>();
            for(Customer_Product_Line_Item__c c: [select id, Combo__c, Name, Customer_Product__r.Name,Condition_1__c, 
                    Condition_2__c,Shape_1__c, Shape_2__c,Defect_Description__c, Opportunity__c from Customer_Product_Line_Item__c where Opportunity__c =: oid]) {

                cplist.add(new cCustomer(c)); 
       }
        return cplist;
    }    


    public PageReference processSelected() {

        for(cCustomer cCon: cplist) {
            if(cCon.selected == true) {
                selectedCpli.add(cCon.con);

            }
               System.debug('#####'+cCon.selected);
        }

        System.debug('These are the selected Contacts...');
        for(Customer_Product_Line_Item__c con: selectedCpli) {
            cpset.add(con.combo__c);
            system.debug(con);
        }
         system.debug(cpset);
        cplist=null;
        return null;
    }

    public List<App_Matrix__c> getConfiguration() {
            aplist = new List<App_Matrix__c>();
            for(App_Matrix__c ac: [select Name, Base_Model__c, Customer_Product__r.name, Condition_1__c, Condition_2__c,Shape_1__c, Shape_2__c,combo__c,Defect_Description__c from App_Matrix__c where combo__c in: cpset]) {

                aplist.add(ac);
                System.debug('%%%%%%%%%%id'+ac.id);

            }
        return aplist;
    }



    public class cCustomer {
        public Customer_Product_Line_Item__c con {get; set;}
        public Boolean selected {get; set;}

        public cCustomer (Customer_Product_Line_Item__c c) {
            con = c;
            selected = false;
        }
    }
    
}

Thank you for your help



 
  • September 01, 2015
  • Like
  • 0
The below code combines two lists as one list and sorts the list.
public with sharing class ProductCostSalesSheet {


    public ProductCostSalesSheet() {
        o = [select id from Opportunity where id =: System.currentpageReference().getParameters().get('oppid')];
        system.debug('*********************000000000:'+ o); 
        oppi = o.id;  
        system.debug('*********************000000001:'+ oppi); 
        
    }

    
    id oppi;
    Public final Opportunity o;
    List<String> prodOption = new List<String>();
    Map<String, String> joinMap = new Map<String, String>();

    public ProductCostSalesSheet(ApexPages.StandardController controller) {
        
        }

      public  List<string> getOppProductOptions(){
      
      prodOption = new List<String>();
      

       for(OpportunityLineItem oli: [select id, Product2.name, unitprice, discount, totalprice, quantity from OpportunityLineItem where OpportunityId =: oppi]){
           joinMap.put(oli.id, oli.id+','+oli.product2.name+','+oli.quantity+','+oli.discount+','+oli.unitprice);
       }
       
       for(Proposal_Option__c p : [select id, Opportunity_Product__c, Description__c,sequence__c,sales_price__c,discount__c,unit_price__c,quantity__c from Proposal_Option__c where Opportunity__c =: oppi]){
           joinMap.put(p.Opportunity_Product__c+p.id, p.Opportunity_Product__c+p.sequence__c+','+p.Description__c+','+p.quantity__c+','+p.discount__c+','+p.unit_price__c);
           system.debug('*********************000000003:'+ joinMap); 
       }
       prodOption = joinMap.values();
      
       prodOption.sort();
    
       return prodOption;
    }

}
The code does the following:
1. Joins mulitple fields into one comma-separated string.
2. Combines two lists into a map, then a list.
3. Sorts the list.
4. returns the list.

How do I now convert the comma-separated string to a list?
 
I am in a project where i have to update all my test classes in my org with the new fields I am creating. A huge time commitment. What is best practice for apex code? Should I configure one class where I have create my test class records or create the test data in each test class? This affects 50+ test classes in my org.
I need to test a validation rule in my test class where the formula field is a date field. From my research, I have developed the code below:

General_Spec_Sheet__c gss2 = new General_Spec_Sheet__c(
       
                            name = 'General Spec Sheet',
                            Opportunity__c = op.id,
                            Customer_Account__c = a.id,
                            Update_Invoice_Billing_Address__c = 'yes',
                            Invoice_to_street__c = '1232 SW Broadway',
                            Invoice_to_City__c = 'Anytown',
                            Invoice_to_State__c = 'AnyState',
                            Invoice_to_Country__c = 'Canada',
                            Invoice_to_Zip_Postal_Code__c = '12345',
                            Technical_Contact__c = con.id,
                            Commercial_Contact__c = con.id,
                            e_mail__c = 'jo@doe.com',
                            phone__c = '5565656456',
                            Update_Technical_Contact_Record__c = 'yes',//Monica
                            Update_Commercial_Contact_Record__c = 'Yes',
                            update__c = 'yes',// Monica
                            Customer_Specific_Standards__c = 'No',
                            fax__c = '1234567898',
                            Generate_Firm_Budget_Quote__c = 'Budget Quote',
                            Requested_Date_to_Complete_Quote__c = date.parse('1/1/2020'));
        try{
             insert gss2;
   

       } Catch(Exception E){
      
       }
    General_Spec_Sheet__c gs = [select id, X3_Day_Minimum_Quote_Due_Date__c from General_Spec_Sheet__c where id=:gss2.id];
     system.debug(' Status Formula Field : ' + gs.X3_Day_Minimum_Quote_Due_Date__c );
     System.assert(gs.X3_Day_Minimum_Quote_Due_Date__c);

I am not able to retrieve the formula value to ttest the validation rule/ How do I retrieve the formula value?

Thank you
ckellie




Below is my entire test class for further reference::

@isTest(SeeAllData=True)
private class TestCreateGeneralSpecSheetListEdit{
   Static CreateGeneralSpecSheetListEdit ext;
   static testMethod void CreateGeneralSpecSheetListEdit () {

    //Setup User
    User u1 = new user (Username = ' test5462@key.net',
                        alias='test',
                        LastName ='test',
                        email='test@key.net',
                        communityNickname='test',
                        TimeZoneSidKey='America/Los_Angeles',
                        LocaleSidKey='en_US',
                        EmailEncodingKey='ISO-8859-1',
                        ProfileId='00e30000000gAkF',
                        LanguageLocaleKey='en_US' );
    insert u1;
         System.runAs(u1) {
         // The following code runs as user 'u1' 
   
         System.debug('Current User: ' + UserInfo.getUserName());
         System.debug('Current Profile: ' + UserInfo.getProfileId()); }

    u1 = [select id from user where alias = 'test'];
   
    //Run as U1

        Test.startTest();
        Account a = new account ( name = 'accounttest', type = 'customer',
        Strategic_Industry__c = 'POT(Potato)', Strategic_Segment__c= 'Chips',
        Strategic_Product__c = 'Kettle chips', billingstreet = '123 south college ave',
        billingcity = 'College Place', billingstate='Washington', billingcountry='United States of America', billingpostalcode ='99324');
        Insert a;
       
        Campaign campaign = new Campaign (name = 'test');
        insert campaign;
       
        Opportunity op = new Opportunity (Recordtypeid = '012300000000Vnm',
                                            Name = 'opportunitytest',
                                            accountid=a.id, //monica
                                            stagename = 'Budget',
                                            CloseDate = date.parse('1/1/2020'),
                                            Amount = 5.00,
                                            INCO_Terms__c = 'FCA',
                                            Campaignid= campaign.id,
                                            Related_Location__c = 'Walla Walla',
                                            Probability_Key_Will_Win_Order__c = 0.01,
                                            ForecastCategoryName = 'Pipeline',
                                            Equip_Services_Options_to_be_quoted__c = 'tegra',
                                            Op_Market_Position__c = '1 - Existing Equip - Existing App/Market (PB items a known app and current cust base)',
                                            Product_1__c = 'apple',
                                            Product1_Condition__c = 'raw',
                                            Product1_Line_Capacity__c = '20000 lbs/hr',
                                            Ready_to_generate_Quote__c = true,
                                            Ready_to_Generate_a_Budget_Quote__c = true,
                                            Requested_date_to_complete_Quote__c = date.parse('1/1/2020'));
        Insert op;
       
        Contact con = new Contact(
                            lastname = 'Doe',
                            Firstname = 'John',
                            email = 'John@does.com',
                            accountid = a.id);
       
        insert con;
    
      
       Customer_Product__c cp = new Customer_Product__c (name ='Apple');
       
        insert cp;
            
        Customer_Product_Line_Item__c cpli = new Customer_Product_Line_Item__c(
                                            name = 'Apple',
                                            customer_Product__c = cp.id,
                                            Opportunity__c = op.id,
                                            Account__c = a.id,
                                            Condition_1__c = 'Raw',
                                            industry_segment__c = 'Pet Food');
       
         insert cpli;

                General_Spec_Sheet__c gss2 = new General_Spec_Sheet__c(
       
                            name = 'General Spec Sheet',
                            Opportunity__c = op.id,
                            Customer_Account__c = a.id,
                            Update_Invoice_Billing_Address__c = 'yes',
                            Invoice_to_street__c = '1232 SW Broadway',
                            Invoice_to_City__c = 'Anytown',
                            Invoice_to_State__c = 'AnyState',
                            Invoice_to_Country__c = 'Canada',
                            Invoice_to_Zip_Postal_Code__c = '12345',
                            Technical_Contact__c = con.id,
                            Commercial_Contact__c = con.id,
                            e_mail__c = 'jo@doe.com',
                            phone__c = '5565656456',
                            Update_Technical_Contact_Record__c = 'yes',//Monica
                            Update_Commercial_Contact_Record__c = 'Yes',
                            update__c = 'yes',// Monica
                            Customer_Specific_Standards__c = 'No',
                            fax__c = '1234567898',
                            Generate_Firm_Budget_Quote__c = 'Budget Quote',
                            Requested_Date_to_Complete_Quote__c = date.parse('1/1/2020'));
        try{
             insert gss2;
   

       } Catch(Exception E){
      
       }
    General_Spec_Sheet__c gs = [select id, X3_Day_Minimum_Quote_Due_Date__c from General_Spec_Sheet__c where id=:gss2.id];
     system.debug(' Status Formula Field : ' + gs.X3_Day_Minimum_Quote_Due_Date__c );
     System.assert(gs.X3_Day_Minimum_Quote_Due_Date__c);

      for(account acct : [select id from account where id =:a.id]){
               if(gss2.Update_Invoice_Billing_Address__c == 'yes'){
               acct.billingstreet = gss2.Invoice_to_street__c;
               acct.billingcity = gss2.Invoice_to_City__c;
               acct.billingstate = gss2.Invoice_to_State__c;
               acct.billingcountry = gss2.Invoice_to_Country__c;
               acct.billingpostalcode = gss2.Invoice_to_Zip_Postal_Code__c;
           update acct;}
          
            system.assertEquals('1232 SW Broadway', acct.billingstreet);
          
           }
        
     Task ta = new Task (
         whatid = op.id,
         subject='Generate a Budget Quote - U.S./Canada',
         ActivityDate = gss2.Requested_Date_to_Complete_Quote__c,
         ownerid= u1.id);
          
           insert ta;
            
      PageReference pageRef2 = Page.GeneralSpecSheetEdit;
   
    pageRef2.getParameters().put('id', gss2.id);

    Test.setCurrentPageReference(pageRef2);
              

        Test.stopTest();
      
                         
        ApexPages.StandardController sc = new ApexPages.StandardController(New General_Spec_Sheet__c());   
      
                           ext = new CreateGeneralSpecSheetListEdit(sc );          
   
   
     String cpUrl = '/apex/GeneralSpecSheetEdit?id=' + gss2.id;

       
        ext.getgess();
        ext.getresults();
        ext.EditGS();
        ext.SendUpdatesandTask();
        ext.CanceltoManage();


           }
   
}
The below trigger is to copy record information from the child (Customer Product Line Items) records to fields on the parent (Opportunity) object, which is the max number of records attached to the Opportunity. Each child record has its own set of fields on the Opportunity. I have bulkified this trigger, is there any addition changes that I need to make to bulkify the trigger?

Here is the trigger:
trigger CustomerProductonOpp on Customer_Product_Line_Item__c (After Insert, Before Update) {

    Set<id> cid = new Set<Id>();
    Set<id> oid = new Set<Id>();
    Map<id, Customer_Product_Line_Item__c> cplimap = new Map<id, Customer_Product_Line_Item__c>();
    Map<id, Opportunity> omap = new Map<id, Opportunity>();

    for(Customer_Product_Line_Item__c cpli : trigger.new){
        cid.add(cpli.id);
        oid.add(cpli.Opportunity__c);
        cplimap.put(cpli.id, cpli);

        }

    for(Opportunity o : [select id from Opportunity where id =: oid]){
        omap.put(o.id, o);
    }

   
    List<Customer_Product_Line_Item__c> cpli = [select id, Product_Field_on_Opportunity__c, Condition_1__c, Condition_2__c, Condition_3__c, Bulk_Density__c,
                                                Defect_Description__c, Capacity__c from Customer_Product_Line_Item__c where id in: cid];
   
    for(Opportunity o : [select id, Product_1_Name__r.id from Opportunity where id =: oid]){
    if(trigger.isInsert){
        if(o.Product_1_Name__c == null && cpli.size()>0){
            o.Product_1_Name__c = cpli[0].id;
            o.Product_1_Primary_Condition__c = cpli[0].Condition_1__c;
            o.Product_1_Additional_Condition_1__c = cpli[0].Condition_2__c;
            o.Product_1_Additional_Condition_2__c = cpli[0].Condition_3__c;
            o.Product_1_Primary_Shape__c = cpli[0].Shape_1__c;
            o.Product_1_Additional_Shape__c = cpli[0].Shape_2__c;
            o.Product_1_Bulk_Density__c = cpli[0].Bulk_Density__c;
            o.Product_1_Sort_Criteria__c = cpli[0].Defect_Description__c;
            o.Product_1_Capacity__c = cpli[0].Capacity__c;
            cpli.remove(0);
        }
        if(o.Product_2_Name__c == null && cpli.size()>0){
            o.Product_2_Name__c = cpli[0].id;
            o.Product_2_Primary_Condition__c = cpli[0].Condition_1__c;
            o.Product_2_Additional_Condition_1__c = cpli[0].Condition_2__c;
            o.Product_2_Additional_Condition_2__c = cpli[0].Condition_3__c;
            o.Product_1_Primary_Shape__c = cpli[0].Shape_1__c;
            o.Product_1_Additional_Shape__c = cpli[0].Shape_2__c;
            o.Product_2_Bulk_Density__c = cpli[0].Bulk_Density__c;
            o.Product_2_Sort_Criteria__c = cpli[0].Defect_Description__c;
            o.Product_2_Capacity__c = cpli[0].Capacity__c;
            cpli.remove(0);
        }

    }
    if(trigger.isUpdate){
     for(Customer_Product_Line_Item__c cp : trigger.new){
         If(o.Product_1_Name__r.id == cp.id){
            o.Product_1_Primary_Condition__c = cp.Condition_1__c;
            o.Product_1_Additional_Condition_1__c = cp.Condition_2__c;
            o.Product_1_Additional_Condition_2__c = cp.Condition_3__c;
            o.Product_1_Primary_Shape__c = cp.Shape_1__c;
            o.Product_1_Additional_Shape__c = cp.Shape_2__c;
            o.Product_1_Bulk_Density__c = cp.Bulk_Density__c;
            o.Product_1_Sort_Criteria__c = cp.Defect_Description__c;
            o.Product_1_Capacity__c = cp.Capacity__c;
         } else
         If(o.Product_2_Name__r.id == cp.id){
            o.Product_2_Primary_Condition__c = cp.Condition_1__c;
            o.Product_2_Additional_Condition_1__c = cp.Condition_2__c;
            o.Product_2_Additional_Condition_2__c = cp.Condition_3__c;
            o.Product_2_Primary_Shape__c = cp.Shape_1__c;
            o.Product_2_Additional_Shape__c = cp.Shape_2__c;
            o.Product_2_Bulk_Density__c = cp.Bulk_Density__c;
            o.Product_2_Sort_Criteria__c = cp.Defect_Description__c;
            o.Product_2_Capacity__c = cp.Capacity__c;
         }

        update o;
     }  
    }
}
The below apex class creates a task when the field Ready_to_Generate_a_Firm_Quote__c == true, and attached the quote to the related Opportunity. he code currently does not send any task. How do I correct the problem?

Here is the class:
public with sharing class CreateGeneralSpecSheetListEdit{

    public CreateGeneralSpecSheetListEdit() {

    }

    ApexPages.StandardController GstdController;
    id oid;
    id aid;
    id gid;
    id eid;
    id tid;
    id cid;
    public List<Customer_Product_Line_Item__c> cpList {get; set;}
    public List<General_Spec_Sheet__c> gList {get; set;}
    public General_Spec_Sheet__c genss;
    public static General_Spec_Sheet__c gs {get; set;}
   
    public CreateGeneralSpecSheetListEdit(ApexPages.StandardController controller) {

       gid = [select id from General_Spec_Sheet__c Where id =:ApexPages.currentPage().getParameters().get('genid') or id =:ApexPages.currentPage().getParameters().get('id')].id;
       tid = [select Technical_Contact__r.id from General_Spec_Sheet__c Where id =:ApexPages.currentPage().getParameters().get('genid') or id =:ApexPages.currentPage().getParameters().get('id')].Technical_Contact__r.id;
       cid = [select Commercial_Contact__r.id from General_Spec_Sheet__c Where id =:ApexPages.currentPage().getParameters().get('genid') or id =:ApexPages.currentPage().getParameters().get('id')].Commercial_Contact__r.id;
       oid = [select Opportunity__r.id, Opportunity__r.Accountid from General_Spec_Sheet__c Where id =:ApexPages.currentPage().getParameters().get('genid') or id =:ApexPages.currentPage().getParameters().get('id')].Opportunity__r.id;
       System.Debug ('********' + oid );
      
       aid = [select Opportunity__r.Accountid from General_Spec_Sheet__c Where id =:ApexPages.currentPage().getParameters().get('genid') or id =:ApexPages.currentPage().getParameters().get('id')].Opportunity__r.Accountid;
       GstdController = controller;
      
       this.genss = (General_Spec_Sheet__c)Controller.getRecord();
    }
   
    public List<Customer_Product_Line_Item__c> getresults() {
        if(cplist == null) {
            cplist = new List<Customer_Product_Line_Item__c>();
            System.Debug('&&&&&&&&&&&' + oid );
            for(Customer_Product_Line_Item__c c: [select id, Name, Opportunity__c, Opportunity__r.SFDC_for_Quote__c,Opportunity__r.AIS__c,
                    Condition_1__c, Condition_2__c, Condition_3__c, Temperature_deg_f__c, Capacity__c, General_Application__c, Shape_1__c,
                    Shape_2__c, Defect_Description__c, Environment_temp_f__c, Capacity_per_lane__c, bulk_density__c, Opportunity__r.PS__c from
                    Customer_Product_Line_Item__c where Opportunity__c =: oid]) {

                cplist.add(c);
            }
        }
        return cplist;
    }
   
    public list<General_Spec_Sheet__c> getgess(){
        if(glist == null) {
            glist = new List<General_Spec_Sheet__c>();
            System.Debug('&&&&&&&&&&&' + oid );
            for(General_Spec_Sheet__c c: [select id, name, Opportunity__c, Customer_Account__c, Seismic_Zone__c, Layout__c, PO_Number__c, App_Test__c,
                    Invoice_to_Street__c, Ship_To_Street__c, Invoice_to_City__c, Ship_to_City__c, Invoice_to_State__c, Ship_to_State__c, Invoice_to_Country__c,
                    Ship_to_Country__c, Invoice_to_Zip_Postal_Code__c, Ship_to_Zip_Postal_Code__c, Update_Invoice_Billing_Address__c, Update__c, Commercial_Contact__c,
                    Commercial_Contact_Phone__c, Commercial_Contact_Street__c, Commercial_Contact_Fax__c, Commercial_Contact_City__c, Commercial_Contact_Title__c,
                    Commercial_Contact_State__c, Commercial_Contact_Email__c, Commercial_Contact_Country__c, Update_Commercial_Contact_Record__c,Ready_to_Generate_a_Firm_Quote__c,
                    Commercial_Contact_Zip_Postal_Code__c, Technical_Contact__c, Phone__c, Update_Technical_Contact_Record__c, Fax__c, Title__c, E_mail__c, File_Type__c,
                    Drawing_Title__c, Customer_Specific_Standards__c, List_Standards__c, Ready_to_Generate_a_Budget_Quote__c, Requested_date_to_complete_Budget_Quote__c,
                    Requested_date_to_complete_Firm_Quote__c from General_Spec_Sheet__c where id =: gid limit 1]) {

                glist.add(c);
            }
        }
        return glist;
    }

    public PageReference EditGS(){
     
   
   PageReference pageRef = new PageReference('/apex/GeneralSpecSheetEdit?genid=' + gid + '&sfdc.override=1');
         pageRef.setRedirect(true);

    return pageRef;
    }


    public PageReference SendUpdatesandTask(){
   
    try{
   
    List<General_Spec_Sheet__c> g = [select id from General_Spec_Sheet__c where id =: gid];
   
    list<Account> acct = [select id from account where id =: aid];
   
    id eotm = [select id from user where Beusichem_Sales_Operations_Manager__c = true].id;
    List<OpportunityTeamMember> uotm = [SELECT Id, OpportunityId, TeamMemberRole, UserId FROM OpportunityTeamMember where TeamMemberRole='Product Specialist' and OpportunityID =: oid];

     update cplist;

//       try{
    update glist;
  //  }
//   catch(Exception e){
       
//   }


     If(glist[0].Update_Invoice_Billing_Address__c == 'Yes'){
         acct[0].BillingStreet = genss.Invoice_to_Street__c;
         acct[0].BillingCity = genss.Invoice_to_City__c;
         acct[0].BillingState = genss.Invoice_to_State__c;
         acct[0].BillingCountry = genss.Invoice_to_Country__c;
         acct[0].BillingPostalCode = genss.Invoice_to_Zip_Postal_Code__c;

        genss.Update_Invoice_Billing_Address__c = 'Updated';

     }
     System.debug('UOTM LIST VALUES :' + uotm);

     If(glist[0].Update__c == 'yes'){
         acct[0].ShippingStreet = genss.Ship_To_Street__c;
         acct[0].ShippingCity = genss.Ship_to_City__c;
         acct[0].ShippingState = genss.Ship_to_State__c;
         acct[0].ShippingCountry = genss.Ship_to_Country__c;
         acct[0].ShippingPostalCode = genss.Ship_to_Zip_Postal_Code__c;
       
        genss.Update__c = 'Updated';
    
        }

     update acct;
    
    List<Contact> com = new List<Contact>([select id from contact where id =: cid]);
    for(Contact co : com){
       if(glist[0].Update_Commercial_Contact_Record__c == 'Yes'){
         co.mailingstreet = genss.commercial_contact_street__c;
         co.mailingcity = genss.commercial_contact_city__c;
         co.mailingstate = genss.commercial_contact_state__c;
         co.mailingcountry = genss.commercial_contact_country__c;
         co.mailingpostalcode = genss.commercial_contact_zip_postal_code__c;
         co.phone = genss.phone__c;
         co.email = genss.e_mail__c;
         co.title = genss.title__c;
         co.fax = genss.fax__c;
        
         genss.Update_Technical_Contact_Record__c = 'Updated';
      

     update co;

        }

     If(glist[0].Ready_to_Generate_a_Budget_Quote__c == true ){
    
         Task ta = new Task();
          ta.whatID = oid;
          ta.subject='Generate a Budget Quote - U.S./Canada';
          ta.ActivityDate = genss.Requested_date_to_complete_Budget_Quote__c;
          ta.ownerid= uotm[0].userid;
              System.debug('2222' + ta.ownerid);
              
        Database.DMLOptions dmlo1 = new Database.DMLOptions();
        dmlo1.EmailHeader.triggerUserEmail = true;
        database.insert(ta, dmlo1);
   
     }
       
   If(glist[0].Ready_to_Generate_a_Firm_Quote__c == true){
   
         Task ta = new Task();
           ta.whatID = oid;        
           ta.subject='Generate a Firm Quote - U.S./Canada';
           ta.ActivityDate= genss.Requested_date_to_complete_Firm_Quote__c;
           ta.ownerid= uotm[0].userid;
          System.debug('2222' + ta.ownerid);
              
        Database.DMLOptions dmlo1 = new Database.DMLOptions();
        dmlo1.EmailHeader.triggerUserEmail = true;
        database.insert(ta, dmlo1);

       } 
       }
      
   PageReference pageRef = new PageReference('/apex/GeneralSpecSheetView?id='+gid+'&genid='+gid);
                pageRef.setRedirect(true);
               
    return pageRef;
    }
    catch(Exception e){
       
    }
    return null;
    }

    public PageReference CanceltoManage(){
   
   PageReference pageRef = new PageReference('/apex/GeneralSpecSheetView?id='+gid+'&genid='+gid);
            pageRef.setRedirect(true);

    return pageRef;
    } 
  
}

Thank you
In this class, i am updating the related opportunity record and sending a task to the product specialist listed on the opportunity team.

This list is not returning any records although I have confirmed a record is created that meets the criteria:

List<OpportunityTeamMember> uotm = [SELECT Id, OpportunityId, TeamMemberRole, UserId FROM OpportunityTeamMember where TeamMemberRole = 'Product Specialist' and OpportunityID =: oid];

How do I correct the query to capture the record in the list?


The complete class:

public with sharing class CreateGeneralSpecSheetListEdit{

    public CreateGeneralSpecSheetListEdit() {

    }

    ApexPages.StandardController GstdController;
    id oid;
    id aid;
    id gid;
    id eid;
    id tid;
    id cid;
    public List<Customer_Product_Line_Item__c> cpList {get; set;}
    public General_Spec_Sheet__c genss;
   
    public CreateGeneralSpecSheetListEdit(ApexPages.StandardController controller) {

       gid = [select id from General_Spec_Sheet__c Where id =:ApexPages.currentPage().getParameters().get('genid') or id =:ApexPages.currentPage().getParameters().get('id')].id;
       tid = [select Technical_Contact__r.id from General_Spec_Sheet__c Where id =:ApexPages.currentPage().getParameters().get('genid') or id =:ApexPages.currentPage().getParameters().get('id')].Technical_Contact__r.id;
       cid = [select Commercial_Contact__r.id from General_Spec_Sheet__c Where id =:ApexPages.currentPage().getParameters().get('genid') or id =:ApexPages.currentPage().getParameters().get('id')].Commercial_Contact__r.id;
       oid = [select Opportunity__r.id, Opportunity__r.Accountid from General_Spec_Sheet__c Where id =:ApexPages.currentPage().getParameters().get('genid') or id =:ApexPages.currentPage().getParameters().get('id')].Opportunity__r.id;
       aid = [select Opportunity__r.Accountid from General_Spec_Sheet__c Where id =:ApexPages.currentPage().getParameters().get('genid') or id =:ApexPages.currentPage().getParameters().get('id')].Opportunity__r.Accountid;
        GstdController = controller;
  
    this.genss = (General_Spec_Sheet__c)GstdController.getRecord();

    }

    public List<Customer_Product_Line_Item__c> getresults() {
        if(cplist == null) {
            cplist = new List<Customer_Product_Line_Item__c>();
            for(Customer_Product_Line_Item__c c: [select id, Name, Opportunity__c, Opportunity__r.SFDC_for_Quote__c,Opportunity__r.AIS__c,
                    Condition_1__c, Condition_2__c, Condition_3__c, Temperature_deg_f__c, Capacity__c, General_Application__c, Shape_1__c,
                    Shape_2__c, Defect_Description__c, Environment_temp_f__c, Capacity_per_lane__c, bulk_density__c, Opportunity__r.PS__c from
                    Customer_Product_Line_Item__c where Opportunity__c =: oid]) {

                cplist.add(c);
            }
        }
        return cplist;
    }

    public PageReference EditGS(){
     
   
   PageReference pageRef = new PageReference('/apex/GeneralSpecSheetEdit?genid=' + gid + '&sfdc.override=1');
         pageRef.setRedirect(true);

    return pageRef;
    }


    List<Opportunity> opp = [select id, Ready_to_Generate_new_Firm_Quote__c, Ready_to_Generate_a_Budget_Quote__c,Requested_date_to_complete_Firm_Quote__c,
                            sfdc_for_quote__c, Opportunity_Region__c, Requested_date_to_complete_Budget_Quote__c from Opportunity where id=:oid];
   
    list<Account> acct = [select id from account where id =: aid];
   
    id eotm = [select id from user where name = 'Sander van Heumann'].id;
    List<OpportunityTeamMember> uotm = [SELECT Id, OpportunityId, TeamMemberRole, UserId FROM OpportunityTeamMember where OpportunityID =: oid];

    public PageReference SaveList(){

        update cplist;

    PageReference pr = GstdController.save();

     If(genss.Update_Invoice_Billing_Address__c == 'Yes'){
         acct[0].BillingStreet = genss.Invoice_to_Street__c;
         acct[0].BillingCity = genss.Invoice_to_City__c;
         acct[0].BillingCountry = genss.Invoice_to_Country__c;
         acct[0].BillingPostalCode = genss.Invoice_to_Zip_Postal_Code__c;

        genss.Update_Invoice_Billing_Address__c = 'Updated';

     }

     If(genss.Update__c == 'yes'){
         acct[0].ShippingStreet = genss.Ship_To_Street__c;
         acct[0].ShippingCity = genss.Ship_to_City__c;
         acct[0].ShippingState = genss.Invoice_to_State__c;
         acct[0].ShippingCountry = genss.Invoice_to_Country__c;
         acct[0].ShippingPostalCode = genss.Invoice_to_Zip_Postal_Code__c;
       
        genss.Update__c = 'Updated';
    
        }

     update acct;
    
    List<Contact> com = new List<Contact>([select id from contact where id =: cid]);
    for(Contact co : com){
       if(genss.Update_Commercial_Contact_Record__c == 'Yes'){
         co.mailingstreet = genss.commercial_contact_street__c;
         co.mailingcity = genss.commercial_contact_city__c;
         co.mailingstate = genss.commercial_contact_state__c;
         co.mailingcountry = genss.commercial_contact_country__c;
         co.mailingpostalcode = genss.commercial_contact_zip_postal_code__c;
         co.phone = genss.phone__c;
         co.email = genss.e_mail__c;
         co.title = genss.title__c;
         co.fax = genss.fax__c;
        
         genss.Update_Technical_Contact_Record__c = 'Updated';
      

     update co;
        }
        }
    for(Opportunity o : [select id, Opportunity_Region__c, Ready_to_Generate_new_Firm_Quote__c, Requested_date_to_complete_Budget_Quote__c,
                            Ready_to_generate_a_Budget_Quote__c, Requested_date_to_complete_Firm_Quote__c from Opportunity where id =:oid]){
     o.Ready_to_Generate_a_Budget_Quote__c = genss.opportunity__r.Ready_to_Generate_a_Budget_Quote__c;
     o.Requested_date_to_complete_Budget_Quote__c = genss.opportunity__r.Requested_date_to_complete_Budget_Quote__c;
     o.Ready_to_Generate_new_Firm_Quote__c = genss.opportunity__r.Ready_to_Generate_new_Firm_Quote__c;
     o.Requested_date_to_complete_Firm_Quote__c = genss.opportunity__r.Requested_date_to_complete_Firm_Quote__c;
         

       
         Task ta = new Task();
           ta.whatID = o.id;
           ta.ActivityDate= o.Requested_date_to_complete_Firm_Quote__c;
               If(o.Opportunity_region__c == 'Europe' && o.Ready_to_Generate_new_Firm_Quote__c == true ){
                   ta.subject='Generate a Firm Quote - Europe';}
               If(o.Opportunity_region__c == 'Europe' && o.Ready_to_Generate_a_Budget_Quote__c == true ){
                   ta.subject='Generate a Budget Quote - Europe';}
               If(o.Opportunity_region__c <> 'Europe' && o.Ready_to_Generate_new_Firm_Quote__c == true ){
                   ta.subject='Generate a Firm Quote - U.S./Canada';}
               If(o.Opportunity_region__c <> 'Europe' && o.Ready_to_Generate_a_Budget_Quote__c == true ){
                   ta.subject='Generate a Budget Quote - U.S./Canada';}
           ta.Agreed_due_date__c = o.Requested_date_to_complete_Firm_Quote__c;
               If(o.Opportunity_region__c == 'Europe'){
                   ta.ownerid= eotm;}
               else{ta.ownerid= uotm[0].id;}
        Database.DMLOptions dmlo1 = new Database.DMLOptions();
        dmlo1.EmailHeader.triggerUserEmail = true;
        database.insert(ta, dmlo1);
        }
      
   PageReference pageRef = new PageReference('/apex/GeneralSpecSheetView?id='+gid+'&genid='+gid);
         pageRef.setRedirect(true);

    return pageRef;
    }

 
    public PageReference CanceltoOpp(){
   
   PageReference pageRef = new PageReference('/'+oid);
         pageRef.setRedirect(true);

    return pageRef;
    }   
 
    public PageReference CanceltoManage(){
   
   PageReference pageRef = new PageReference('/apex/GeneralSpecSheetView?id='+gid+'&genid='+gid);
         pageRef.setRedirect(true);

    return pageRef;
    }   
}

Thank you
I currently am updating a custom object's strategic industry based on the user choosing the industry segment, then apex code is looking up the coorrelating strategic industry. Below is the code

Map<string, Industry_Definition__c> imap = new Map<string, Industry_Definition__c>();
   
    for(Industry_Definition__c i : [select id, Market_Segment__c, Strategic_Industry__c from Industry_Definition__c]){
        imap.put(i.Market_Segment__c, i);
        system.debug('##########i.Market_segment__c:'+ i.market_segment__c);
    }
                     
     for( Integer i = 0; i < Trigger.new.size(); i++){
            trigger.new[i].Strategic_Industry__c = imap.get(trigger.new[i].industry_Segment__c).Strategic_Industry__c;
    }

I need to extend thefunctionality to populate the strategic industry on the related account with the same value as the strategic industry on the trigger.new record. I am trying to use the code below to update the account strategic industry
Map<id, Customer_Product_Line_Item__c> cmap = new Map<id, Customer_Product_Line_Item__c>(Trigger.new);
   
    Account[] relatedaccount = new List<Account>(); relatedaccount = [select id, Strategic_Industry__c from account
        where id in:cmap.keyset()];

    for(Account a : relatedaccount){
        a.Strategic_Industry__c = imap.get(cmap.industry_segment__c).Strategic_Industry__c;
    }

The above code is returning the following error:
Error: Compile Error: Initial term of field expression must be a concrete SObject: MAP<Id,Customer_Product_Line_Item__c> at line 20 column 44


Here is the entire trigger:
trigger IndustrytoAcctOpp on Customer_Product_Line_Item__c (Before Insert, Before Update) {

    Map<string, Industry_Definition__c> imap = new Map<string, Industry_Definition__c>();
   
    for(Industry_Definition__c i : [select id, Market_Segment__c, Strategic_Industry__c from Industry_Definition__c]){
        imap.put(i.Market_Segment__c, i);
        system.debug('##########i.Market_segment__c:'+ i.market_segment__c);
    }
                     
     for( Integer i = 0; i < Trigger.new.size(); i++){
            trigger.new[i].Strategic_Industry__c = imap.get(trigger.new[i].industry_Segment__c).Strategic_Industry__c;
    }
   
    Map<id, Customer_Product_Line_Item__c> cmap = new Map<id, Customer_Product_Line_Item__c>(Trigger.new);
   
    Account[] relatedaccount = new List<Account>(); relatedaccount = [select id, Strategic_Industry__c from account
        where id in:cmap.keyset()];

    for(Account a : relatedaccount){
        a.Strategic_Industry__c = imap.get(cmap.industry_segment__c).Strategic_Industry__c;
    }

}

How do I solve this problem?
Thank you
In this trigger, I am looking up the strategic industry based on the market segment in the Industry Definition table. My problem is I cannot commit the resulting industry value to the original record. I have tried to achieve my objective through the admin tools and cannot. How do I save the resulting strategic industry value to customer_product_line_item___c record?

Thank you very much.

trigger IndustrytoAcctOpp on Customer_Product_Line_Item__c (Before Insert, Before Update) {

    Set<Id> iid = new Set<Id>();
    Set<Id> aid = new Set<Id>();
    Set<Id> oid = new Set<Id>();
    String Industry;
    String Marketsegment;
    string StrategicIndustry;
   
    For(Customer_Product_Line_Item__c cpli : trigger.new){
        iid.add(cpli.id);
        aid.add(cpli.Account__c);
        oid.add(cpli.Opportunity__c);
        MarketSegment = cpli.industry_segment__c;
        system.debug('##########marketsegment:'+ marketsegment);
    }

    List<Industry_Definition__c> idlist = new List<Industry_Definition__c> ([select id, Market_segment__c, Strategic_Industry__c from Industry_Definition__c]);
   
    Map<string, Industry_Definition__c> imap = new Map<string, Industry_Definition__c>();
   
    for(Industry_Definition__c i : [select id, Market_Segment__c, Strategic_Industry__c from Industry_Definition__c]){
        imap.put(i.Market_Segment__c, i);
        system.debug('##########i.Market_segment__c:'+ i.market_segment__c);
    }
                     

    For(Customer_Product_Line_Item__c cpl : [select id, Bulk_Density__c, Industry_Segment__c, Strategic_Industry__c from Customer_Product_Line_Item__c where id=:iid]){
        system.debug('##########imap.get(cpl.industry_Segment__c):'+ cpl.industry_Segment__c);
        system.debug('##########imap.get(cpl.industry_Segment__c).Strategic_Industry__c:'+imap.get(cpl.industry_Segment__c).Strategic_Industry__c);
        cpl.Strategic_Industry__c = imap.get(cpl.industry_Segment__c).Strategic_Industry__c;

    }

}

I have found  javascript function that saves the visualforce page:

 

<script type='text/javascript'>
    function noenter(ev)  {
        if (window.event && window.event.keyCode == 13 || ev.which == 13) {
            doSearchAF();
            return false;
         } else {
              return true;
         }
     }
</script>
 

 Field functionality:

        <apex:inputfield value="{!PCN__c.Account__c}" label="Customer Name" required="true" onkeypress="return noenter(event);" styleclass="searchStr"  />

 How do I change the javascriptt from saving the record to advancing the cursor from one field to the next field?

Thank you

Below is my for loop to insert records:

 

     
       List<Customer_Product_Summary__c> cslist = new List<Customer_Product_Summary__c>([select id, customer_Product_catalog__c,Primary_Condition__c, account__c from Customer_Product_Summary__c where account__c =: o.accountid]);
     
   for(cCustomer p : getsummary())
   {
        system.debug('@@@@@@@$$$$$:'+p);  

      Customer_Product_Summary__c cs = new Customer_Product_Summary__c();
    
    cs.Account__c = o.accountid;
    cs.Customer_Product_Catalog__c = p.con.id;
    cs.name = p.con.name;  
    cs.Primary_Condition__c = p.con.Condition_1__c;
    cs.Primary_Shape__c = p.con.Shape_1__c;
    cs.Defect_Description__c = p.con.Defect_Description__c;
    cs.Capacity__c = p.con.Capacity__c;
    cs.Bulk_Density__c = p.con.Bulk_Density__c;
    cs.Industry_Segment__c = p.con.Industry_Segment__c;

    If(cs.Customer_Product_Catalog__c!=null){
      try {
      item1.add(cs);
 system.debug('#######################'+cs);
      } catch(System.DMLException e) {
        ApexPages.addMessages(e);

      }    
     }

 

Add the condition to only create the record if cs.Customer_Product_Catalog__c contains a unique value when the record is added to the list 'cslist'?

Thanks

 

  • September 09, 2013
  • Like
  • 0