Creating a note by the current user  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Creating a note by the current user

Postby neil.interactit » Thu Feb 16, 2017 4:50 pm

Hey guys,

No doubt I'm missing the obvious somewhere. I need to create a note by the current user ...

Code: Select all
        var note = new Note() { NoteText = "MY NOTE TEXT", LastModifiedByStaffMember = Manager.Instance.Staff, LastSavedDateTime = DateTime.Now, NoteType = _creditorForm.Creditor.Notes.DefaultNoteType };
        _creditorForm.Creditor.Notes.Add(note);

But I cannot implicitly convert type 'JiwaFinancials.Jiwa.JiwaApplication.JiwaStaff.clsStaff' to 'JiwaFinancials.Jiwa.JiwaApplication.Entities.Staff.Staff'. How do I get the Entity.Staff of the current user?

Cheers,
Neil.
neil.interactit
Kohai
Kohai
 
Posts: 227
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6

Re: Creating a note by the current user  Topic is solved

Postby Mike.Sheen » Thu Feb 16, 2017 4:59 pm

The long way is to create an new instance of a JiwaApplication.Entities.Staff.Staff and do a .ReadRecord, passing in the Manager.Instance.Staff.RecID, then set LastModifiedByStaffMember to be that entity.

For example:

Code: Select all
var staff = new JiwaApplication.Entities.Staff.Staff();
staff.ReadRecord(Manager.Instance.Staff.RecID);
var note = new Note() { NoteText = "MY NOTE TEXT", LastModifiedByStaffMember = staff, LastSavedDateTime = DateTime.Now, NoteType = _creditorForm.Creditor.Notes.DefaultNoteType };
_creditorForm.Creditor.Notes.Add(note);
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Creating a note by the current user

Postby neil.interactit » Mon Feb 20, 2017 9:17 am

Easy! Many thanks Mike.

Cheers,
Neil
neil.interactit
Kohai
Kohai
 
Posts: 227
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6

Re: Creating a note by the current user

Postby neil.interactit » Thu Oct 10, 2019 9:47 am

Hi Mike,

Code: Select all
_creditorForm.Creditor.Notes.DefaultNoteType

appears to be depreciated in 7.2.1, and I can't spot what to migrate to, could you advise?

Cheers,
Neil
neil.interactit
Kohai
Kohai
 
Posts: 227
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6

Re: Creating a note by the current user

Postby SBarnes » Thu Oct 10, 2019 6:50 pm

Hi Neil,

Mike or Scott might give you an easier option but this should work, if you use JiwaFinancials.Jiwa.JiwaApplication.Notes.NoteTypeCollection and call read after setting the notetype (its a string) to "JiwaFinancials.Jiwa.JiwaCreditors.Creditor" that will give you all the note types for creditors and then there is a function on the collection called GetDefaultNoteType which will give you the default.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1617
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Creating a note by the current user

Postby neil.interactit » Fri Oct 11, 2019 11:00 am

Thanks Stuart,

Sweet ...

Code: Select all
var defaultNoteType = new NoteTypeCollection { NoteType = "JiwaFinancials.Jiwa.JiwaCreditors.Creditor" }.GetDefaultNoteType();

Many thanks.
neil.interactit
Kohai
Kohai
 
Posts: 227
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6

Re: Creating a note by the current user

Postby Scott.Pearce » Fri Oct 11, 2019 2:38 pm

Code: Select all
var defaultNoteType = new NoteTypeCollection { NoteType = "JiwaFinancials.Jiwa.JiwaCreditors.Creditor" }.GetDefaultNoteType();


Make sure you use a factory when creating Jiwa objects, or you may have problems. Plus, I don't see you reading in the above code, so you won't get anything back.

Here's the code I would use (untested):

Code: Select all
var noteTypes = Manager.CollectionFactory.CreateCollection<NoteTypeCollection, NoteType>();
noteTypes.NoteType = "JiwaFinancials.Jiwa.JiwaCreditors.Creditor";
noteTypes.Read();
var defaultNoteType = noteTypes.GetDefaultNoteType();
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Re: Creating a note by the current user

Postby Mike.Sheen » Fri Oct 11, 2019 2:40 pm

Why do you need the default note type anyway? If you add a new note, if you don't specify the note type, it will set the note type to be the default for you anyway.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron