map with list as value in SOQL - list

I'm working on a small project in Salesforce where a customer can be the master in a master-detail relationship to more than a single project object.
Projects have a currency 'Max_Budget__c' and what I want to do is calculate the max budget per customer by adding the Max_Budget__c per project. This means that I need to collect a List per customer but also need customer stored so I can update the Max_budget__c object of it.
I was thinking about storing it in a Map with Customer__c as key and Set as value, But I'm not sure how to do this in a single SOQL Query or if i'm even looking in the right direction. Any ideas?
Thanks in advance

Let suppose you have multiple projects like project1, project2 etc .
Each has many to one relationship with customer.
i.e many project1 records to single customer record.
many project2 records to single customer record and so on.
so each customer would have many project1 records,project2 records etc..
To calculate max budget per customer you need to calculate max budget from all project1 records,max budget from all project2 records etc..from each customer and add.
So the requirement is simple write a roll up summary on each child(each project) and add all roll up summaries into a custom field.
I hope this will help you or please let me know if anything else needed.
Regards,
Naveen
Automated deployments , Dataloader , Sandbox back-ups, test automation for Salesforce applications

Related

How to assign multiple salesperson to customers?

This is a basic customer card:
As you can see there is a "Salesperson" linked to the customer, but in many situations customers can have multiple salespersons.
In this field I can only select one salesperson.
The problem created by this situation in the company is that sales people can't find customers that are not linked to them.
How can I assign multiple salesperson to customers?
If your salespeople are in fixed groups e.g. person A and B handle the same group of customers and C and D handle another group of customers, you could use the Responsibility Center feature.
Create a Responsibility Center for each group of customers and assign it to those customers. Then set the Sales Resp. Ctr. Filter on the User Setup for each Salesperson.
Using this field, obviously, you can't. You need to use some other field like department or customer group I don't know. Or if I remember correctly the was a table like ’My Customers’ where every user can build a list of customers he's interested in.

How do I turn on cost controls at user level on BigQuery?

Felipe Hoffa wrote this very helpful guide on how to turn on custom cost control for a project in BigQuery. However, according to the doc, it should be possible to configure custom cost control as user level as well. I really need to do this for my production data warehouse project because I can't let one person's mishap stop all the other users from using the data warehouse. Please help!
Go to console.cloud.google.com > I&AM > Quotas. Then filter by bigquery in the services dropdown. You will find a row like the one bellow:
You are looking to edit the Query usage per day per user. To calculate the number of Bytes you can use a service like: https://convertlive.com/u/convert/terabytes/to/bytes#1

Django create a view to generate a receipt

I want to create a small app that creates a kind off receipt record in to a db table, from two other tables. very much like a receipt from a grocery store where a cashier makes a sell and the ticket contains multiple items, calculates a total and subtotal and return values to the database. I currently have 3 tables: the Ticket table where i would like to insert the values of all calculations and ticket info, the services table that acts like an inventory of services available. this has the service name and price for each service and my responsible table that has a list of "cashiers" or people that will make the sale and their percentage for their commissions, i have the views to create , edit and delete cashier's and services.
What I don't have is a way to create the ticket. I am completely lost. can you guys point me in to the correct path on what to look for. i am learning to program son i don't have a lot of knowledge in this if its even possible. i don't need the system to print i just want to have all record stored this way later on i can expand on it and create reports of sold items and who sold them and how much commissions each seller has won.
You need to create relationships to two other models (tables) from the Ticket model (table). Luckily you don't have to create the relations in the database tables itself. Use django model's Foreign key fields to accomplish this. Here is the documentation link:
Django Models
You may need to read it several times to get the concepts thoroughly.

Set Sharepoint task due date based on workflow status

I'm new to SharePoint but most of it seems pretty straight forward but I've hit a problem and haven't been able to find a way around it so far.
I'm trying to set/enforce Service Level Agreements (SLA's) for different departments based on the department the task is assigned to. I was going to do this based on the workflow status that generates the task but am open to any other suggestions.
My workflow for requesting funds for an approved project goes through several stages (Project management validation, Finance Admin validation; Finance manager validation, Fixed assets authorization) and each one has a slightly different SLA. For this reason, I cant just add an arbitrary value to the start date for the calculated column associated to the task.
Any suggestions?
The option I'd go with here is to use If/Then blocks in my workflow code based on the current stage. Something like this:
If Stage = Project Management Validation Then
Set DueDate to Today+5
Else If Stage = Finance Admin Validation Then
Set DueDate to Today+3
etc.
Hope this helps!

Django Copy Related Data and keep them unchanged over time

Using ForeignKey relationships, I want to be able to copy data and store it in another model. For example, think of how you would handle past Invoices and billed Services.
The Invoice would have one or more Services associated with it and with prices for the Services. This prices for a Service can / will change over time - but the Service price recorded with the Invoice should remain as it was when the Invoice was created.
My first thought was to create a pdf from the resulting data and store it. But this would make the data somewhat inaccessible.
Is there somehow a way to copy the data and keep them accessible?
This is a pretty broad problem with multiple solutions. I dont think that what you're aiming to is the correct one.
One rule for saving invoices is, that invoices never change. You should never update an invoice. So not only your 'copies' of invoices should remain the same, but the original too.
Also, you should have a InvoiceItem (or InvoiceRow) model which are the items on your invoice. Don't bind Products to a Invoice directly.
Here are 2 solutions I've used:
Solution 1
You can normalize the data on your invoice(items). So, don't use foreignkeys, but normalize all data about the product, so product info (incl. price) is saved within the invoice(item).
Solution 2
Give your products revision numbers. So everytime a product is updated (name or price change for example), a new product is created in the database. Now you can link the InvoiceItem to a Product with a Foreign Key, and it will will be historically accurate.
Im sure there are some guides/best practices for creating Invoice backends. Language or Framework is not important. Invoicing is really important, so do alot of research before starting to build something. That's just my two pennies