You need to sign in to do that
Don't have an account?
Robert Wambold 10
Is it possible to use a Forward Slash ("\") in a Text field?
Hi All,
I have a user request where the User would like a Path to a Windows Directory created from Salesforce data.
I originally tried using Apex, but APex did not like the Forward Slash. So I thought I would create Text Field on the Object with Forward Slash as the default value, but this was not allowed.
Any suggestions o should I just tell the user no. I hate saying no.
Goal is to create MyOpsPath = '\\MyFiles\MyFolder\';
It is possible with apex code you can try like this.
Trigger code:
----------------------------
trigger AccountTrigger on Account (before insert, before update) {
if(Trigger.isBefore) {
if(Trigger.isInsert) {
AccountHandler.onBeforeSave(Trigger.New);
}
if(Trigger.isUpdate) {
AccountHandler.onBeforeSave(Trigger.New);
}
}
}
Apex class:
-------------------
public with sharing class AccountHandler {
public static void onBeforeSave(List<Account> accountList) {
String appedingValue = '\\';
for(Account acc : accountList) {
acc.Name = appedingValue + acc.Name;
}
}
}
I hope this helps.
All Answers
It is possible with apex code you can try like this.
Trigger code:
----------------------------
trigger AccountTrigger on Account (before insert, before update) {
if(Trigger.isBefore) {
if(Trigger.isInsert) {
AccountHandler.onBeforeSave(Trigger.New);
}
if(Trigger.isUpdate) {
AccountHandler.onBeforeSave(Trigger.New);
}
}
}
Apex class:
-------------------
public with sharing class AccountHandler {
public static void onBeforeSave(List<Account> accountList) {
String appedingValue = '\\';
for(Account acc : accountList) {
acc.Name = appedingValue + acc.Name;
}
}
}
I hope this helps.
Prakash,
Thank you for your help. I am now able to create the desired path,
MyOpsPath__c=(Slash2+Slash2+PthLit1+Slash2+'sqman'+Slash2+PthLit2+Slash2+Ctgry+Slash2+LstAccts[0].Site+Slash2);
Robert