Change Agent field to match Opp Owner name when Opp owner changes on lead conversion and manually changes by supervisor staff - workflow

I have tried using workflows using criteria for everytime a lead converts to an opportunity. And also process builder. But I am fairly new to this and I always hit a snag when it comes to matching the Opportunity Owner name to the Agent field.

Related

Taking the Name of the ROLE the user is in and populating it to a pick-list on the Opportunity

My customer has created roles with the names of the company's business divisions and sub-divisions. He wants to take the role the creating user is in, along with the next level up Role and populate that into two fields on the opportunity, to then use those two fields. (ROLE and SUB-ROLE) as Dashboard filters. Since the role is in the setup section and is also not a field on the user record, I'm assuming some type of Apex Trigger or Flow would be needed to take the role names of the creating user and then insert them?
They are new to Salesforce.. they have not tried anything yet.

I have to apply trigger on employee object and get id of project and stored data of Project Assignment

My Question is
Create a Record of Project with Name = Default and leave all other fields blank.
When an employee is created using the trigger, create a record for project assignment and it should be mapped with the Default record (created above)
I have created a record of project but I don't know how we mapped to project and projext assignment.

How does Oracle SQL resolve naming conflicts between synonyms and tables?

I have a public synonym on my server for transactions: However I'd like to be able to work with my own local version of the table, so as not to disturb other users.
Does Oracle's SQL resolve naming conflicts like this in a predictable fashion?
In other words, if another user creates a public synonym called TRANSACTION and I do this:
CREATE TABLE TRANSACTION (
ID NUMBER
);
When I write
select * from TRANSACTION
Do I have any guarantee that Oracle will always resolve the synonym or my local table?
(I know I could technically specify schema.TRANSACTION to force the issue, but in my case that would require me to modify/rebuild an application and I'm hoping to save some work.)
Your understanding of name resolution is correct. Oracle will first look in the current schema to find an object with that name. So, In case of a conflict, It will choose an object in the current schema instead of the object referred to by the public synonym.
http://docs.oracle.com/cd/B28359_01/server.111/b28310/general008.htm
Oracle Database attempts to qualify the first piece of the name
referenced in the SQL statement. For example, in scott.emp, scott is
the first piece. If there is only one piece, the one piece is
considered the first piece.
In the current schema, the database searches for an object whose name
matches the first piece of the object name. If it does not find such
an object, it continues with step b.
The database searches for a public synonym that matches the first
piece of the name. If it does not find one, it continues with step c.
The database searches for a schema whose name matches the first piece
of the object name. If it finds one, it returns to step b, now using
the second piece of the name as the object to find in the qualified
schema. If the second piece does not correspond to an object in the
previously qualified schema or there is not a second piece, the
database returns an error.
If no schema is found in step c, the object cannot be qualified and
the database returns an error.
Having said that, this is one of the problems with public synonyms. Having objects like this will lead to confusion down the road, both for development and support. You are better off referencing the object by owner and name in both cases

Create record in related table *only* if not previously existing there

I have a Filemaker database with a Members table, an Events table, and a join table called Attendance which should list which members attended which events. Attendance has the setting "allow creation of new records" ticked for Members (doesn't need it for Events).
Data arrives in an Excel spreadsheet for importing to Attendance. But then I want to see if there are people attending who aren't in our records already... sort of like this:
look at each of the newly added records in the attendance table
see if the members mentioned there exist in the member table
if so, do nothing
else create a new record in the member table for them, using data from the attendance table.
If I'm understanding it correctly, Steps 3 and 4 should look something like this:
Set Variable [ $fname; Value: Attendance::firstname ]
Go To Layout ["Member" (Firstname)]
New Record/Request
Set Field [Member::Firstname; $fname]
i.e. put the desired info into variables, start a new record in the related table and set the data there to the value of the variables.
But how do I get step 2 happening? I'm guessing some sort of loop will go through the found set of records in Attendance, and grab the relevant identifier. How do I show that to the Member table to see if it's present or not?
"Firstname" might be a bit light to pinpoint a unique member, if you have many members !
I'd presume therefore you would have some sort of unique key for each member.
As from there, just search for the member in the member base, before creating the new record…
Link the two tables with an EQUALS relationship.
Write a script:
// Loop through your attendance records.
// Be sure you're in the correct layout
Go to Layout ["imported list"]
// Attempt to go to the membership record of the person who is attending the event.
Go to Related Record [Show only records from: from table: "membership table"; using layout: "membership table"
// If the person who is attending IS in the membership list, you'll go to that member's record in the "membership table."
// If the person who is attending is NOT in the membership list, you'll get an error. You can use that error in an if statement to execute code to add that member.
If [Get ( LastError ) = "101"]
// insert code to add new member
End if
Since you already have a relationship between Member and Attendance, it means that you can "see" any related Members from the Attendance table across the relationship.
We also know that you only need to evaluate the new attendance records coming in from your spreadsheet.
I also assume that there could possibly be be more than one attendance record per Member in the spreadsheet. This may not be the case, but it's safer to assume it's possible.
I'm also assuming that you are linking the Member table to the Attendance table via the primary key in Members and a foreign key in Attendance, i.e. Member::ID = Attendance::Member ID.
So here's the script process I suggest:
Import the new Attendance record into the Attendance table.
This will give you a found set of only new attendance records
From the Attendance layout, perform a find for related Member records with an omit, i.e.:
# This assumes you're already on the Attendance layout
Enter Find Mode
Set field [Member::ID ; "*"]
Omit record
Constrain Find
This will give you a found set of new Attendance records that do not have matching Member records.
From here you could loop through each of the attendance records and create the Member records as needed.
If you check the Allow creation on the Member side of the Member -< Attendance relationship, you could set the field in the Member table directly from the Attendance layout.
Since the 1 to Many relationship between Member and Attendance goes 1=Member Many=Attendance, you would need to check to be sure you haven't already created a Member record during your loop, i.e. If a new Member had multiple Attendance records you could have already created a Member record during the loop.
Your loop would look like this:
Go to Record [First]
Loop
If [IsEmpty(Member::ID)]
Set Field [Member::First Name] // This first Set Field will create your new Member Record as long as the "Allow Creation" is enabled on the Member side
Set Field [Member::Last Name]
... This would be the rest of your set field steps for Member
End If
Go to Record [Next ; Exit After Last]
End Loop
This way you don't need to navigate away from your Attendance record set. Also, the Primary and Foreign keys for both tables will be created and set automatically through the attributes of the relationship itself.

How to handle entity versions in SQL Server?

I have a SQL Server 2008 R2 database that contains a table that holds my entities from an ad.
It looks something like this :
Title
Price
CreatedDate
UpdatedDate
Description
EndDate
PublishedDate
StateOfProduct
Id
UserId
UserLocationId
Visits
CategoryId
TypeOfAd
AdminComment
ReviewedDate
AmountOfImages
UserPostCode
UserEmail
UserPhoneNr
UserPassword
OwnerType
AdminUserId
InactivatedDate
OldPrice
PriceLastChange
An Ad entity can have the following stages : Published, Waiting for review, Outdated.
Say that the ad is published and the customer decides to edit the ad, this means that the settings on the ad above will change. A change like this demands a new review and that means that the ad will go from Published to Waiting for review.
The problem with this is that when a ad is changed and is waiting for review it is not published anymore.
What I need is to let the ad be published with the old (reviewed) data and when the review is done of the updated ad it will switch places but keep the old id.
The question is how to handle this the right way?
I Suppose that I could have two identical tables to keep record count down and to make it simpler to find published ads but it will be a lot more work to use Entity Framework against two identical tables at the same time.
Another solution might be to add two extra columns in the Ads table that holds the version of the ad and the original adId. The flow will in this case be something like this :
Create Ad(id=1), originalId = null, version = null.
Review Ad(id=1)
Publish Ad(id=1), version = 1
Customer Updates Ad, new Ad(id=2) is created with version set to null(=waiting for review) and originalId = 1
Reviewed Ad(id=2) done, Ad(id=1) will be copied to a new records (id = 3 (or2)), originalId set to 1. Ad(id=2) will be moved/copied to Ad(id1), originalId = null, version = 2.
The ad table might however be vary large with this but it will be a lot easier to trace ads history.
I believe this could be done using many approaches, it's just a matter of preference. What I would do is make a new table named, say, ReviewedAds with int Id, int AdId, bit Reviewed. 1:many relationship with Ads table so AdId from this table is a foreign key and matches Id from Ads table. Then I would display only those ads whose Reviewed bit is set to '1'. Two records in ReviewedAds couldn't have the same AdId and Reviewed bit set to '1'.