How to correctly set groups in TradeCaptureReport? - quickfix

I'm trying to set the groups correctly for the TradeCaptureReport from DTO. The first side is always the Buyer and the second is the Seller.
I have such an example, but it is badly done, could someone help how to set it up correctly?
public static TradeCaptureReport mapToTrade(TradeMessageDTO tradeMessageDTO) {
final TradeCaptureReport tradeCaptureReport = new TradeCaptureReport();
tradeCaptureReport.setField(new LastPx(tradeMessageDTO.getLastPx()));
tradeCaptureReport.setField(new LastQty(tradeMessageDTO.getLastQty()));
tradeCaptureReport.setField(new Symbol(tradeMessageDTO.getSymbol()));
tradeCaptureReport.setField(new TransactTime(LocalDateTime.now()));
tradeCaptureReport.setField(new TradeDate(tradeMessageDTO.getTradeDate()));
tradeCaptureReport.setField(new TradeReportTransType(tradeMessageDTO.getTradeReportTransType()));
tradeCaptureReport.setField(new PreviouslyReported(getPreviouslyReported(tradeMessageDTO)));
tradeCaptureReport.setField(new TradeReportID(tradeMessageDTO.getTradeReportID()));
tradeCaptureReport.setField(new TrdType(tradeMessageDTO.getTrdType()));
tradeCaptureReport.setField(new NoSides(tradeMessageDTO.getNoSides()));
Group group1 = new Group(1, NoSides.FIELD); // BUY SIDE
group1.setField(new Side(tradeMessageDTO.getBuyerSide().getSide()));
group1.setField(new OrderID(tradeMessageDTO.getBuyerSide().getOrderID()));
group1.setField(new NoPartyIDs(tradeMessageDTO.getBuyerSide().getNoPartyIDs()));
group1.setField(new PartyID(tradeMessageDTO.getBuyerSide().getPartyID()));
group1.setField(new PartyIDSource(tradeMessageDTO.getBuyerSide().getPartyIDSource()));
group1.setField(new PartyRole(tradeMessageDTO.getBuyerSide().getPartyRole()));
group1.setField(new Account(tradeMessageDTO.getBuyerSide().getAccount()));
group1.setField(new TradingSessionID(tradeMessageDTO.getBuyerSide().getTradingSessionID()));
Group group2 = new Group(2, NoSides.FIELD); // SELL SIDE
group2.setField(new Side(tradeMessageDTO.getSellerSide().getSide()));
group2.setField(new OrderID(tradeMessageDTO.getSellerSide().getOrderID()));
group2.setField(new NoPartyIDs(tradeMessageDTO.getSellerSide().getNoPartyIDs()));
group2.setField(new PartyID(tradeMessageDTO.getSellerSide().getPartyID()));
group2.setField(new PartyIDSource(tradeMessageDTO.getSellerSide().getPartyIDSource()));
group2.setField(new PartyRole(tradeMessageDTO.getSellerSide().getPartyRole()));
group2.setField(new Account(tradeMessageDTO.getSellerSide().getAccount()));
group2.setField(new TradingSessionID(tradeMessageDTO.getSellerSide().getTradingSessionID()));
tradeCaptureReport.addGroup(group1);
tradeCaptureReport.addGroup(group2);
return tradeCaptureReport;
}
Unfortunately, the groups do not line up correctly, I get a duplicate tag 1 and tag 2 which I have not added anywhere at all, Have any of you faced a similar problem? Regards :)

Check this page for a simple example:
https://www.quickfixj.org/usermanual/2.3.0/usage/repeating_groups.html
Specific to your code I'd suggest the following:
Do not set the NoSides field by yourself. It will be done implicitly by QFJ when you add the group to the message.
Do not create a general Group but use TradeCaptureReport.NoSides().
Do not set contents of the Party group inside the NoSides group field by field but use the specific group TradeCaptureReport.NoSides.NoPartyIDs().

Related

I have a question on apex trigger when an account zip code is changed then change the account owner to the sales representative to the new zip code

When an Account’s BillingPostalCode (aka Zip Code), is changed,
Change the Account Owner to the sales representative assigned to the new zip code
Change the Owner field of all the Account’s Contacts to the same sales rep
Change the Owner field of all the Account’s Open Opportunities to the same sales rep
Note:
● The logic should run only when the Account’s zip code is changed or populated for the
first time
● If no matching Territories are found, do nothing
Requirement #3: Multiple sales representatives can be assigned to the same zip code territory.
If this is the case, use a random function to select one of the assigned sales representatives.
Requirement #4: Three sales representatives at most can be assigned to a single zip code.
Display an error if a user attempts to associate another sales representative to a zip code
trigger FireBolt on Account (before insert,before update)
{
Map<Id,String> oldZip = new Map<Id,String>();
Map<Id,String> newZip = new Map<Id,String>();
Territory1__c t = new Territory1__c();
Set ZipCodes = new Set();
List <Territory1__c> trlist= new List<Territory1__c>();
trlist = [SELECT Id,Name,OwnerId,Zip_Code__c,Sales_Representative__c FROM Territory1__c Where Zip_Code__c IN : ZipCodes];
for(Account a : Trigger.New)
{
ZipCodes.add(a.id);
}
if(Trigger.IsUpdate && Trigger.IsInsert)
{
for(Account a:Trigger.New)
{
//checking if the Account BillingPostalCode Zip code value has changed during update
String newZipCode = Trigger.newMap.get(a.id).BillingPostalCode;
String oldZipCode = Trigger.oldMap.get(a.id).BillingPostalCode;
if(newZipCode != oldZipCode)
{
oldZip.put(a.Id, Trigger.oldMap.get(a.Id).BillingPostalCode);
newZip.put(a.Id, a.OwnerId);
ZipCodes.add(a.Id);
newZipCode= t.Sales_Representative__c;
a.OwnerId= t.Sales_Representative__c;
}
}
}
}
please guide me I am new to salesforce

How do I assign usernames to a ROBLOX Team Spawner?

I would like to know how to assign certain usernames to a team spawner.
Basically when a certain username joins the game, they get placed into a team on the leader board and spawn at the correct spawn in game.
You can do this by checking the username and assigning the team. So something like this, assuming you don't have teams already set up.
team = Instance.new("Team",game:GetService'Teams')
game:GetService'Players'.PlayerAdded:connect(function(p)
if p.Name == "name" then
p.Team = team
end
end
Obviously you can set the team name and color through this script or create it your own.
You have to do the player handling yourself. Basically you want to listen on new players with PlayerAdded and set the team (based on some kind of magical function) with Team.
However you can assign Spawners to a team by setting the TeamColor to equal the Team's TeamColor.
Example code:
local Teams = game:GetService("Teams")
local RedTeam = Teams["Red Team"]
local OtherTeam = Teams["Other Team"]
local PlayersInTeamRed = { "Player1" , "Player2" }
game:GetService("Players").PlayerAdded:connect(function(player)
for playerName in ipairs(PlayersInTeamRed) do
if player.Name == playerName then
player.Team = RedTeam
return
end
end
-- Maybe another list here
-- not in "Team red"
player.Team = OtherTeam
end)
Note that you might want to check against the UserId instead, because some players changes their name.
Also make sure that the Spawn's Neutral value is false.

Get sheets belonging to a specific group

How do I tell if a sheet belongs to a certain group?
For example, we have a group called RPR and when we create sheets we share them with other users in our organization applying the group to the sheet.
// Get all sheets modified within last day
SmartSheetList = smartsheet
.SheetResources
.ListSheets(new SheetInclusion[] { SheetInclusion.OWNER_INFO }, new PaginationParameters(true, null, null))
.Data
.Where(d => d.ModifiedAt.Value.Date >= DateTime.Now.AddDays(-1).Date)
.ToList();
// Get organization sheets
var orgUserSheets = smartsheet.UserResources.SheetResources.ListSheets(true).Data.ToList();
// get specific group
var group = smartsheet.GroupResources.ListGroups(null).Data.Where(grp => grp.Id == some-id-here).First();
With the code above I can see if a sheet belongs to an organization but I can't tell if that sheet belongs to a certain group. Any help would be appreciated.
You need one more API Request for each sheet to retrieve the list of shares on the sheet. Keep in mind, sheets can be shared directly on the sheet or via a workspace.
To get sheets that are shared with a specific group directly or via a workspace, you can use code something like the below (relying on LINQ for this sample).
SmartsheetClient cl = new SmartsheetBuilder()
.SetAccessToken(ACCESS_TOKEN)
.Build();
var includeAll = new PaginationParameters(true, null, null);
Console.WriteLine("Looking for group " + SOUGHT_GROUP_NAME);
var groups = cl.GroupResources.ListGroups(includeAll);
var soughtGroup = groups.Data.Single((group) => group.Name == SOUGHT_GROUP_NAME);
Console.WriteLine("Found group ID {0} for group {1}.", soughtGroup != null ? soughtGroup.Id.ToString() : "NULL", SOUGHT_GROUP_NAME);
if (soughtGroup == null)
throw new ArgumentException("Group not found");
var sheets = cl.SheetResources.ListSheets(null, includeAll);
Console.WriteLine("Querying through {0} sheets...", sheets.Data.Count);
var sheetsSharedWithGroup = from sheet in sheets.Data
from share in cl.SheetResources.ShareResources.ListShares(sheet.Id.Value, includeAll, ShareScope.Workspace).Data
where share.GroupId == soughtGroup.Id
select new { Sheet = sheet, Share = share };
var found = sheetsSharedWithGroup.ToList();
Console.WriteLine("Found {0} sheets shared with group {1}.", found.Count, SOUGHT_GROUP_NAME);
found.ForEach(foundSheet => Console.WriteLine("Sheet {0} shared with {1} ({2})", foundSheet.Sheet.Name, foundSheet.Share.Name, foundSheet.Share.Type));
NOTE: I submitted a pull request to add support for the specific ListShares overload that returns workspace shares too. This is available in the REST API but wasn't yet in the C# SDK.
NOTE: The above code does not take into account Smartsheet Sights yet. It should be possible using the corresponding REST API for Sights (i.e. List Sights, List Sight Shares, but I don't think that's in the C# SDK yet.

Bugzilla email_in.pl reference several cc addresses

When a case is created from an e-mail, I would like the list of cc present in the e-mail to be added to my default bugzilla cc list.
I was able to do it with a single cc by doing :
my ($cc_address) = Email::Address->parse($input_email->header('Cc'));
$fields('cc') = $cc_address->address;
However, what if I have several addresses, I can capture them by doing :
my (#cc_address) = Email::Address->parse($input_email->header('Cc'));
then I am not sure about how to assign the list to $fields('cc').I don't think the field does expect a list.
Does anyone have an idea ?
Not tested, but have you tried:
my (#cc_address) = Email::Address->parse($input_email->header('Cc'));
my $cc_as_string = join ",", #cc_address;
$fields('cc') = $cc_as_string

Titanium.Contacts.showContacts , alphabetically first name

I am using Titanium to develop a mobile app. I have stuck in a problem, where i want to show contact list. I used the following code to show contact list
Titanium.Contacts.showContacts({ });
I am getting the contact list, but it shows in sorting order of last name . I want the list to be shown in sorting order of first name.
Any help will be appreciated
there is a property Ti.Contacts.CONTACTS_SORT_FIRST_NAME hope this helps. There is also CONTACTS_KIND_ORGANIZATION, and CONTACTS_KIND_PERSON.
var g = Ti.Contacts.getAllGroups( );//Getting all the groups on the contacts table
var m = g[0].members();//select a group and check if it has members
Ti.API.info(m)// my group was empty so i have to add people
var p = Ti.Contacts.getAllPeople( )// get all the contacts
for (var i in p){//group and add people to your group
g[0].add(p[i]);
Ti.API.info(p[i].firstName);
Titanium.Contacts.save()// you have to save new changes in IOS
}
g[0].sortedMembers(Ti.Contacts.CONTACTS_SORT_FIRST_NAME);// FINALLY WE CAN SORT
m = g[0].members();// get the members
for (var i in m){// verify they are in order
Ti.API.info(m[i].firstName);
}